Skip to content

Commit e9f2d60

Browse files
authored
Merge pull request #1109 from sdroege/clippy-warnings
Clippy warnings
2 parents 4b17e9a + 17b15b6 commit e9f2d60

File tree

9 files changed

+23
-18
lines changed

9 files changed

+23
-18
lines changed

cairo/src/svg.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,11 @@ mod test {
146146
*surface.finish_output_stream().unwrap().downcast().unwrap()
147147
}
148148

149+
#[track_caller]
149150
fn assert_len_close_enough(len_a: usize, len_b: usize) {
150151
// It seems cairo randomizes some element IDs which might make one svg slightly
151152
// larger than the other. Here we make sure the difference is within ~10%.
152-
let len_diff = (len_a as isize - len_b as isize).abs() as usize;
153+
let len_diff = usize::abs_diff(len_a, len_b);
153154
assert!(len_diff < len_b / 10);
154155
}
155156

glib-macros/src/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ mod tests {
248248
.required()
249249
.value_required();
250250
let _ = parse_nested_meta_items(&input.attrs, "boxed_type", &mut [&mut gtype_name]);
251-
assert_eq!(gtype_name.get_found(), true);
251+
assert!(gtype_name.get_found());
252252
assert_eq!(
253253
gtype_name.value.map(|x| x.value()),
254254
Some("Author".to_string())
@@ -271,6 +271,6 @@ mod tests {
271271
assert!(gtype_name.value.is_none());
272272

273273
// The argument key must be found though
274-
assert_eq!(gtype_name.get_found(), true);
274+
assert!(gtype_name.get_found());
275275
}
276276
}

glib/src/translate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -958,7 +958,7 @@ macro_rules! impl_to_glib_container_from_slice_fundamental {
958958
}
959959

960960
unsafe {
961-
let res = ffi::g_malloc(mem::size_of::<$name>() * t.len()) as *mut $name;
961+
let res = ffi::g_malloc(mem::size_of_val(t)) as *mut $name;
962962
ptr::copy_nonoverlapping(t.as_ptr(), res, t.len());
963963
res
964964
}

pangocairo/Gir.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ single_version_file = true
1010
deprecate_by_min_version = true
1111
trust_return_value_nullability = true
1212

13-
generate = [
14-
"PangoCairo.Font",
15-
]
13+
generate = []
1614

1715
manual = [
1816
"cairo.Context",
@@ -101,15 +99,21 @@ status = "generate"
10199
name = "cr"
102100
const = true
103101

102+
[[object]]
103+
name = "PangoCairo.Font"
104+
status = "generate"
105+
trait_name = "PangoCairoFontExt"
106+
104107
[[object]]
105108
name = "PangoCairo.FontMap"
106109
status = "generate"
107-
manual_traits = ["FontMapExtManual"]
110+
trait_name = "PangoCairoFontMapExt"
111+
manual_traits = ["PangoCairoFontMapExtManual"]
108112
[[object.function]]
109113
# Needed because cairo types don't implement `.into_glib()`.
110114
name = "get_font_type"
111115
manual = true
112-
doc_trait_name = "FontMapExtManual"
116+
doc_trait_name = "PangoCairoFontMapExtManual"
113117
[[object.function]]
114118
# Needed because cairo types don't implement `.into_glib()`.
115119
name = "new_for_font_type"

pangocairo/src/auto/font.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ impl Font {
1818
pub const NONE: Option<&'static Font> = None;
1919
}
2020

21-
pub trait FontExt: IsA<Font> + 'static {
21+
pub trait PangoCairoFontExt: IsA<Font> + 'static {
2222
#[doc(alias = "pango_cairo_font_get_scaled_font")]
2323
#[doc(alias = "get_scaled_font")]
2424
fn scaled_font(&self) -> Option<cairo::ScaledFont> {
@@ -30,7 +30,7 @@ pub trait FontExt: IsA<Font> + 'static {
3030
}
3131
}
3232

33-
impl<O: IsA<Font>> FontExt for O {}
33+
impl<O: IsA<Font>> PangoCairoFontExt for O {}
3434

3535
impl fmt::Display for Font {
3636
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

pangocairo/src/auto/font_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ impl FontMap {
2525
}
2626
}
2727

28-
pub trait FontMapExt: IsA<FontMap> + 'static {
28+
pub trait PangoCairoFontMapExt: IsA<FontMap> + 'static {
2929
#[doc(alias = "pango_cairo_font_map_get_resolution")]
3030
#[doc(alias = "get_resolution")]
3131
fn resolution(&self) -> f64 {
@@ -40,7 +40,7 @@ pub trait FontMapExt: IsA<FontMap> + 'static {
4040
}
4141
}
4242

43-
impl<O: IsA<FontMap>> FontMapExt for O {}
43+
impl<O: IsA<FontMap>> PangoCairoFontMapExt for O {}
4444

4545
impl fmt::Display for FontMap {
4646
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

pangocairo/src/auto/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ pub mod functions;
1212

1313
#[doc(hidden)]
1414
pub mod traits {
15-
pub use super::font::FontExt;
16-
pub use super::font_map::FontMapExt;
15+
pub use super::font::PangoCairoFontExt;
16+
pub use super::font_map::PangoCairoFontMapExt;
1717
}

pangocairo/src/font_map.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use glib::{prelude::*, translate::*};
44

55
use crate::FontMap;
66

7-
pub trait FontMapExtManual: IsA<FontMap> + 'static {
7+
pub trait PangoCairoFontMapExtManual: IsA<FontMap> + 'static {
88
#[doc(alias = "pango_cairo_font_map_get_font_type")]
99
#[doc(alias = "get_font_type")]
1010
fn font_type(&self) -> cairo::FontType {
1111
unsafe { ffi::pango_cairo_font_map_get_font_type(self.as_ref().to_glib_none().0).into() }
1212
}
1313
}
1414

15-
impl<O: IsA<FontMap>> FontMapExtManual for O {}
15+
impl<O: IsA<FontMap>> PangoCairoFontMapExtManual for O {}
1616

1717
impl FontMap {
1818
#[doc(alias = "pango_cairo_font_map_new_for_font_type")]

pangocairo/src/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ pub use glib::prelude::*;
55
#[doc(hidden)]
66
pub use pango::prelude::*;
77

8-
pub use crate::{auto::traits::*, font_map::FontMapExtManual};
8+
pub use crate::{auto::traits::*, font_map::PangoCairoFontMapExtManual};

0 commit comments

Comments
 (0)