mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 05:44:52 +00:00
const-field-offset: fix a bunch of clippy warnings in tests
This commit is contained in:
parent
73ec3e6701
commit
4af34a8de1
3 changed files with 7 additions and 10 deletions
|
@ -17,4 +17,3 @@ field-offset = "0.3.2"
|
|||
|
||||
[dev-dependencies]
|
||||
memoffset = "0.6"
|
||||
lazy_static = "1.4.0"
|
||||
|
|
|
@ -100,8 +100,8 @@ mod tests {
|
|||
// Get a pointer to `b` within `Foo`
|
||||
let foo_b = Foo::FIELD_OFFSETS.b;
|
||||
let foo_b_pin = unsafe { foo_b.as_pinned_projection() };
|
||||
let foo = Box::pin(Foo { a: 21, b: 22.0, c: true });
|
||||
let pb: Pin<&f64> = foo_b_pin.apply_pin(foo.as_ref());
|
||||
let foo_object = Box::pin(Foo { a: 21, b: 22.0, c: true });
|
||||
let pb: Pin<&f64> = foo_b_pin.apply_pin(foo_object.as_ref());
|
||||
assert_eq!(*pb, 22.0);
|
||||
|
||||
let mut x = Box::pin(Bar { x: 0, y: Foo { a: 1, b: 52.0, c: false } });
|
||||
|
|
|
@ -8,8 +8,8 @@
|
|||
Please contact info@sixtyfps.io for more information.
|
||||
LICENSE END */
|
||||
use const_field_offset::*;
|
||||
use lazy_static::lazy_static;
|
||||
use memoffset::offset_of;
|
||||
use std::sync::atomic::Ordering::SeqCst;
|
||||
|
||||
#[derive(FieldOffsets)]
|
||||
#[repr(C)]
|
||||
|
@ -111,9 +111,7 @@ fn test_pin() {
|
|||
assert_eq!(D_STATIC_PIN, offset_of!(MyStructPin, d));
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref DROP_CALLED: std::sync::Mutex<bool> = std::sync::Mutex::new(false);
|
||||
}
|
||||
static DROP_CALLED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
|
||||
|
||||
#[derive(FieldOffsets)]
|
||||
#[repr(C)]
|
||||
|
@ -125,15 +123,15 @@ struct MyPinnedStructWithDrop {
|
|||
|
||||
impl PinnedDrop for MyPinnedStructWithDrop {
|
||||
fn drop(self: core::pin::Pin<&mut MyPinnedStructWithDrop>) {
|
||||
*DROP_CALLED.lock().unwrap() = true;
|
||||
DROP_CALLED.store(true, SeqCst);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_pin_drop() {
|
||||
*DROP_CALLED.lock().unwrap() = false;
|
||||
DROP_CALLED.store(false, SeqCst);
|
||||
{
|
||||
let _instance = Box::pin(MyPinnedStructWithDrop { x: 42 });
|
||||
}
|
||||
assert!(*DROP_CALLED.lock().unwrap());
|
||||
assert!(DROP_CALLED.load(SeqCst));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue