Skip to content

Commit a2a02a5

Browse files
committed
Fix a couple of trivial clippy warnings
1 parent 4b17e9a commit a2a02a5

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
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
}

0 commit comments

Comments
 (0)