Skip to content

Commit 14e00c8

Browse files
committed
Group imports and use prelude
1 parent 33d3499 commit 14e00c8

File tree

246 files changed

+1290
-1597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

246 files changed

+1290
-1597
lines changed

cairo/src/context.rs

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use crate::font::{
4-
FontExtents, FontFace, FontOptions, Glyph, ScaledFont, TextCluster, TextExtents,
5-
};
6-
use crate::matrices::Matrix;
7-
use crate::paths::Path;
8-
use crate::Rectangle;
9-
use crate::{
10-
Antialias, Content, FillRule, FontSlant, FontWeight, LineCap, LineJoin, Operator,
11-
TextClusterFlags,
12-
};
3+
use std::{ffi::CString, fmt, mem::MaybeUninit, ops, ptr, slice};
4+
135
#[cfg(feature = "use_glib")]
146
use glib::translate::*;
15-
use std::ffi::CString;
16-
use std::fmt;
17-
use std::mem::MaybeUninit;
18-
use std::ops;
19-
use std::ptr;
20-
use std::slice;
21-
22-
use crate::error::Error;
23-
use crate::ffi::{cairo_rectangle_list_t, cairo_t};
24-
use crate::patterns::Pattern;
25-
use crate::surface::Surface;
26-
use crate::utils::status_to_result;
7+
8+
use crate::{
9+
ffi::{cairo_rectangle_list_t, cairo_t},
10+
utils::status_to_result,
11+
Antialias, Content, Error, FillRule, FontExtents, FontFace, FontOptions, FontSlant, FontWeight,
12+
Glyph, LineCap, LineJoin, Matrix, Operator, Path, Pattern, Rectangle, ScaledFont, Surface,
13+
TextCluster, TextClusterFlags, TextExtents,
14+
};
2715

2816
pub struct RectangleList {
2917
ptr: *mut cairo_rectangle_list_t,
@@ -958,12 +946,11 @@ impl fmt::Display for Context {
958946

959947
#[cfg(test)]
960948
mod tests {
961-
use super::*;
962-
use crate::enums::Format;
963-
use crate::image_surface::ImageSurface;
964-
use crate::patterns::LinearGradient;
965949
use float_eq::float_eq;
966950

951+
use super::*;
952+
use crate::{enums::Format, image_surface::ImageSurface, patterns::LinearGradient};
953+
967954
fn create_ctx() -> Context {
968955
let surface = ImageSurface::create(Format::ARgb32, 10, 10).unwrap();
969956
Context::new(&surface).expect("Can't create a Cairo context")

cairo/src/device.rs

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use crate::enums::DeviceType;
4-
use crate::error::Error;
5-
use crate::utils::status_to_result;
6-
7-
use std::fmt;
8-
use std::ptr;
3+
#[cfg(any(feature = "script", feature = "dox"))]
4+
use std::ffi::CString;
5+
#[cfg(any(feature = "script", feature = "dox"))]
6+
use std::path::Path;
7+
use std::{fmt, ptr};
98

109
#[cfg(feature = "use_glib")]
1110
use glib::translate::*;
1211

12+
use crate::{utils::status_to_result, DeviceType, Error};
1313
#[cfg(any(feature = "script", feature = "dox"))]
14-
use crate::enums::Content;
15-
#[cfg(any(feature = "script", feature = "dox"))]
16-
use crate::enums::ScriptMode;
17-
#[cfg(any(feature = "script", feature = "dox"))]
18-
use crate::recording_surface::RecordingSurface;
19-
#[cfg(any(feature = "script", feature = "dox"))]
20-
use crate::surface::Surface;
21-
#[cfg(any(feature = "script", feature = "dox"))]
22-
use std::ffi::CString;
23-
#[cfg(any(feature = "script", feature = "dox"))]
24-
use std::path::Path;
14+
use crate::{Content, RecordingSurface, ScriptMode, Surface};
2515

2616
#[derive(Debug)]
2717
#[must_use = "if unused the Device will immediately be released"]

cairo/src/enums.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
use std::fmt::{self, Debug};
44

5-
use crate::error::Error;
6-
75
#[cfg(feature = "use_glib")]
86
use glib::translate::*;
97

8+
use crate::Error;
9+
1010
// Helper macro for our GValue related trait impls
1111
#[cfg(feature = "use_glib")]
1212
macro_rules! gvalue_impl {

cairo/src/error.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use std::fmt::Debug;
4-
use std::io;
3+
use std::{fmt::Debug, io};
4+
55
use thiserror::Error;
66

77
#[derive(Error, Debug, Clone, PartialEq, Copy, Eq)]

cairo/src/font/font_face.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
#[cfg(feature = "use_glib")]
4-
use glib::translate::*;
53
use std::ffi::{CStr, CString};
64
#[cfg(not(feature = "use_glib"))]
75
use std::ptr;
86
#[cfg(any(feature = "freetype", feature = "dox"))]
97
use std::rc::Rc;
108

11-
use crate::{
12-
enums::{FontSlant, FontType, FontWeight},
13-
Error,
14-
};
9+
#[cfg(feature = "use_glib")]
10+
use glib::translate::*;
1511

1612
#[cfg(any(feature = "freetype", feature = "dox"))]
17-
use crate::enums::FtSynthesize;
18-
19-
use crate::utils::status_to_result;
13+
use crate::FtSynthesize;
14+
use crate::{utils::status_to_result, Error, FontSlant, FontType, FontWeight};
2015

2116
#[cfg(any(feature = "freetype", feature = "dox"))]
2217
static FT_FACE_KEY: crate::UserDataKey<freetype::face::Face> = crate::UserDataKey::new();

cairo/src/font/font_options.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
#[cfg(feature = "use_glib")]
4-
use glib::translate::*;
5-
use std::cmp::PartialEq;
6-
use std::hash;
7-
8-
#[cfg(any(feature = "v1_16", feature = "dox"))]
9-
use crate::font::font_face::to_optional_string;
103
#[cfg(any(feature = "v1_16", feature = "dox"))]
114
use std::ffi::CString;
125
#[cfg(not(feature = "use_glib"))]
136
use std::ptr;
7+
use std::{cmp::PartialEq, hash};
148

15-
use crate::utils::status_to_result;
16-
use crate::{
17-
enums::{Antialias, HintMetrics, HintStyle, SubpixelOrder},
18-
Error,
19-
};
9+
#[cfg(feature = "use_glib")]
10+
use glib::translate::*;
11+
12+
#[cfg(any(feature = "v1_16", feature = "dox"))]
13+
use crate::font::font_face::to_optional_string;
14+
use crate::{utils::status_to_result, Antialias, Error, HintMetrics, HintStyle, SubpixelOrder};
2015

2116
#[cfg(feature = "use_glib")]
2217
glib::wrapper! {

cairo/src/font/mod.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ mod text_cluster;
99
mod text_extents;
1010
mod user_fonts;
1111

12-
pub use crate::enums::{
13-
Antialias, FontSlant, FontType, FontWeight, HintMetrics, HintStyle, SubpixelOrder,
14-
TextClusterFlags,
15-
};
16-
1712
/* TODO
1813
Allocates an array of cairo_glyph_t's. This function is only useful in
1914
implementations of cairo_user_scaled_font_text_to_glyphs_func_t where the user
@@ -39,12 +34,12 @@ impl TextCluster {
3934
//pub fn cairo_text_cluster_free(clusters: *TextCluster);
4035
}
4136
*/
42-
43-
pub use self::font_extents::FontExtents;
44-
pub use self::font_face::FontFace;
45-
pub use self::font_options::FontOptions;
46-
pub use self::glyph::Glyph;
47-
pub use self::scaled_font::ScaledFont;
48-
pub use self::text_cluster::TextCluster;
49-
pub use self::text_extents::TextExtents;
50-
pub use self::user_fonts::UserFontFace;
37+
pub use self::{
38+
font_extents::FontExtents, font_face::FontFace, font_options::FontOptions, glyph::Glyph,
39+
scaled_font::ScaledFont, text_cluster::TextCluster, text_extents::TextExtents,
40+
user_fonts::UserFontFace,
41+
};
42+
pub use crate::enums::{
43+
Antialias, FontSlant, FontType, FontWeight, HintMetrics, HintStyle, SubpixelOrder,
44+
TextClusterFlags,
45+
};

cairo/src/font/scaled_font.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3+
use std::{ffi::CString, mem::MaybeUninit, ptr};
4+
35
#[cfg(feature = "use_glib")]
46
use glib::translate::*;
5-
use std::ffi::CString;
6-
use std::mem::MaybeUninit;
7-
use std::ptr;
8-
9-
use crate::matrices::Matrix;
10-
use crate::utils::status_to_result;
11-
use crate::{enums::FontType, Error, FontExtents, Glyph, TextCluster, TextExtents};
127

13-
use super::{FontFace, FontOptions};
8+
use crate::{
9+
utils::status_to_result, Error, FontExtents, FontFace, FontOptions, FontType, Glyph, Matrix,
10+
TextCluster, TextExtents,
11+
};
1412

1513
#[cfg(feature = "use_glib")]
1614
glib::wrapper! {

cairo/src/font/user_fonts.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

33
use super::{FontExtents, FontFace, ScaledFont, TextCluster, TextClusterFlags, TextExtents};
4-
use crate::utils::status_to_result;
5-
use crate::{Context, Error, Glyph};
4+
use crate::{utils::status_to_result, Context, Error, Glyph};
65

76
type BoxInitFunc =
87
Box<dyn Fn(&ScaledFont, &Context, &mut FontExtents) -> Result<(), Error> + Send + Sync>;

cairo/src/image_surface.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,17 @@
11
// Take a look at the license at the top of the repository in the LICENSE file.
22

3-
use std::convert::TryFrom;
4-
use std::ops::{Deref, DerefMut};
5-
use std::rc::Rc;
6-
use std::slice;
3+
use std::{
4+
convert::TryFrom,
5+
fmt,
6+
ops::{Deref, DerefMut},
7+
rc::Rc,
8+
slice,
9+
};
710

8-
use crate::enums::{Format, SurfaceType};
9-
use crate::error::Error;
1011
#[cfg(feature = "use_glib")]
1112
use glib::translate::*;
1213

13-
use crate::surface::Surface;
14-
use crate::utils::status_to_result;
15-
use crate::BorrowError;
16-
use std::fmt;
14+
use crate::{utils::status_to_result, BorrowError, Error, Format, Surface, SurfaceType};
1715

1816
declare_surface!(ImageSurface, SurfaceType::Image);
1917

@@ -338,7 +336,8 @@ mod tests {
338336
#[cfg(feature = "use_glib")]
339337
#[test]
340338
fn surface_gvalues() {
341-
use glib::ToValue;
339+
use glib::prelude::*;
340+
342341
let surface = ImageSurface::create(Format::ARgb32, 10, 10).unwrap();
343342
let value = surface.to_value();
344343
assert_eq!(value.get::<ImageSurface>().unwrap().width(), 10);

0 commit comments

Comments
 (0)