Skip to content

Commit 61c52d8

Browse files
committed
Fix the build failure from #13
1 parent e94cf0f commit 61c52d8

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/backend.rs

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@ pub struct CairoBackend<'a> {
1515
init_flag: bool,
1616
}
1717

18+
19+
#[derive(Debug)]
20+
pub struct CairoError;
21+
22+
impl std::fmt::Display for CairoError {
23+
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
24+
write!(fmt, "{:?}", self)
25+
}
26+
}
27+
28+
impl std::error::Error for CairoError {}
29+
1830
impl<'a> CairoBackend<'a> {
1931
fn set_color(&self, color: &BackendColor) {
2032
self.context.set_source_rgba(
@@ -355,7 +367,9 @@ mod test {
355367
let buffer: Vec<u8> = vec![];
356368
let surface = cairo::PsSurface::for_stream(500.0, 500.0, buffer).unwrap();
357369
let cr = CairoContext::new(&surface).unwrap();
358-
let root = CairoBackend::new(&cr, (500, 500)).into_drawing_area();
370+
let root = CairoBackend::new(&cr, (500, 500))
371+
.unwrap()
372+
.into_drawing_area();
359373

360374
// Text could be rendered to different elements if has whitespaces
361375
let mut chart = ChartBuilder::on(&root)
@@ -396,7 +410,9 @@ mod test {
396410
let (width, height) = (1500, 800);
397411
let surface = cairo::PsSurface::for_stream(width.into(), height.into(), buffer).unwrap();
398412
let cr = CairoContext::new(&surface).unwrap();
399-
let root = CairoBackend::new(&cr, (width, height)).into_drawing_area();
413+
let root = CairoBackend::new(&cr, (width, height))
414+
.unwrap()
415+
.into_drawing_area();
400416
let root = root
401417
.titled("Image Title", ("sans-serif", 60).into_font())
402418
.unwrap();
@@ -461,7 +477,9 @@ mod test {
461477
let (width, height) = (500_i32, 500_i32);
462478
let surface = cairo::PsSurface::for_stream(width.into(), height.into(), buffer).unwrap();
463479
let cr = CairoContext::new(&surface).unwrap();
464-
let root = CairoBackend::new(&cr, (width as u32, height as u32)).into_drawing_area();
480+
let root = CairoBackend::new(&cr, (width as u32, height as u32))
481+
.unwrap()
482+
.into_drawing_area();
465483

466484
let style = TextStyle::from(("sans-serif", 20).into_font())
467485
.pos(Pos::new(HPos::Center, VPos::Center));
@@ -492,7 +510,9 @@ mod test {
492510
let (width, height) = (500, 500);
493511
let surface = cairo::PsSurface::for_stream(width.into(), height.into(), buffer).unwrap();
494512
let cr = CairoContext::new(&surface).unwrap();
495-
let root = CairoBackend::new(&cr, (width, height)).into_drawing_area();
513+
let root = CairoBackend::new(&cr, (width, height))
514+
.unwrap()
515+
.into_drawing_area();
496516

497517
let mut chart = ChartBuilder::on(&root)
498518
.caption("All series label positions", ("sans-serif", 20))
@@ -552,7 +572,9 @@ mod test {
552572
let (width, height) = (100_i32, 100_i32);
553573
let surface = cairo::PsSurface::for_stream(width.into(), height.into(), buffer).unwrap();
554574
let cr = CairoContext::new(&surface).unwrap();
555-
let root = CairoBackend::new(&cr, (width as u32, height as u32)).into_drawing_area();
575+
let root = CairoBackend::new(&cr, (width as u32, height as u32))
576+
.unwrap()
577+
.into_drawing_area();
556578

557579
for i in -20..20 {
558580
let alpha = i as f64 * 0.1;

0 commit comments

Comments
 (0)