Debian Codegraph @

tests/test.rs

raw symbols SCIP
1 // Take a look at the license at the top of the repository in the LICENSE file.
2
3 use glibrust-analyzer cargo glib 0.22.5 crate/::{
4 collectionsrust-analyzer cargo glib 0.22.5 collections/::Slicerust-analyzer cargo glib 0.22.5 collections/slice/Slice#,
5 preluderust-analyzer cargo glib 0.22.5 prelude/::*,
6 translaterust-analyzer cargo glib 0.22.5 translate/::{FromGlibrust-analyzer cargo glib 0.22.5 translate/FromGlib#, IntoGlibrust-analyzer cargo glib 0.22.5 translate/IntoGlib#},
7 };
8
9 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
10 fn derive_error_domainrust-analyzer cargo glib-macros 0.22.6 derive_error_domain().() {
11 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, glibrust-analyzer cargo glib 0.22.5 crate/::ErrorDomainrust-analyzer cargo glib-macros 0.22.2 ErrorDomain:)]
12 #[error_domain(name = "TestError")]
13 enum TestErrorrust-analyzer cargo glib-macros 0.22.6 TestError# {
14 Invalidrust-analyzer cargo glib-macros 0.22.6 TestError#Invalid#,
15 Badrust-analyzer cargo glib-macros 0.22.6 TestError#Bad#,
16 Wrongrust-analyzer cargo glib-macros 0.22.6 TestError#Wrong#,
17 }
18
19 let err = glibrust-analyzer cargo glib 0.22.5 crate/::Errorrust-analyzer cargo glib 0.22.5 error/Error#::newrust-analyzer cargo glib 0.22.5 error/impl#[Error]new().(TestErrorrust-analyzer cargo glib-macros 0.22.6 TestError#::Badrust-analyzer cargo glib-macros 0.22.6 TestError#Bad#, "oh no!");
20 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(err.isrust-analyzer cargo glib 0.22.5 error/impl#[Error]is().::<TestErrorrust-analyzer cargo glib-macros 0.22.6 TestError#>());
21 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(matchesrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/matches!!(err.kindrust-analyzer cargo glib 0.22.5 error/impl#[Error]kind().::<TestErrorrust-analyzer cargo glib-macros 0.22.6 TestError#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(TestErrorrust-analyzer cargo glib-macros 0.22.6 TestError#::Badrust-analyzer cargo glib-macros 0.22.6 TestError#Bad#)));
22 }
23
24 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
25 fn derive_shared_arcrust-analyzer cargo glib-macros 0.22.6 derive_shared_arc().() {
26 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
27 struct MyInnerSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerShared# {
28 foorust-analyzer cargo glib-macros 0.22.6 MyInnerShared#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
29 }
30 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, glibrust-analyzer cargo glib 0.22.5 crate/::SharedBoxedrust-analyzer cargo glib-macros 0.22.2 SharedBoxed:)]
31 #[shared_boxed_type(name = "MyShared")]
32 struct MySharedrust-analyzer cargo glib-macros 0.22.6 MyShared#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<MyInnerSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerShared#>);
33
34 let t = MySharedrust-analyzer cargo glib-macros 0.22.6 MyShared#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[MyShared][StaticType]static_type().();
35 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::BOXEDrust-analyzer cargo glib 0.22.5 types/impl#[Type]BOXED.));
36 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "MyShared");
37
38 let p = MySharedrust-analyzer cargo glib-macros 0.22.6 MyShared#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(MyInnerSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerShared# {
39 foorust-analyzer cargo glib-macros 0.22.6 MyInnerShared#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("bar"),
40 }));
41
42 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyShared#0.), 1);
43 let v = p.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyShared][ToValue]to_value().();
44 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyShared#0.), 2);
45 let p_clone = v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MySharedrust-analyzer cargo glib-macros 0.22.6 MyShared#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().();
46 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyShared#0.), 3);
47 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(p_clone);
48 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyShared#0.), 2);
49 droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/drop().(v);
50 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyShared#0.), 1);
51 }
52
53 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
54 fn derive_shared_arc_nullablerust-analyzer cargo glib-macros 0.22.6 derive_shared_arc_nullable().() {
55 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)]
56 struct MyInnerNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared# {
57 foorust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
58 }
59 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::SharedBoxedrust-analyzer cargo glib-macros 0.22.2 SharedBoxed:)]
60 #[shared_boxed_type(name = "MyNullableShared", nullable)]
61 struct MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#<MyInnerNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#>);
62
63 let t = MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[MyNullableShared][StaticType]static_type().();
64 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::BOXEDrust-analyzer cargo glib 0.22.5 types/impl#[Type]BOXED.));
65 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "MyNullableShared");
66
67 let p = MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(MyInnerNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared# {
68 foorust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("bar"),
69 }));
70
71 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0.), 1);
72 let _v = p.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyNullableShared][ToValue]to_value().();
73 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0.), 2);
74
75 let p = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T>`]new().(
76 MyInnerNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared# {
77 foorust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#foo.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("foo"),
78 },
79 )));
80
81 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0.), 1);
82 let v = p.to_valuerust-analyzer cargo glib 0.22.5 value/impl#[`Option<T>`][ToValue]to_value().();
83 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#::strong_countrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/impl#[`Arc<T, A>`]strong_count().(&p.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0.), 2);
84 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
85 p.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().().0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0..foorust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#foo.,
86 v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().0rust-analyzer cargo glib-macros 0.22.6 MyNullableShared#0..foorust-analyzer cargo glib-macros 0.22.6 MyInnerNullableShared#foo.
87 );
88
89 let b: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
90 let v = b.to_valuerust-analyzer cargo glib 0.22.5 value/impl#[`Option<T>`][ToValue]to_value().();
91 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableSharedrust-analyzer cargo glib-macros 0.22.6 MyNullableShared#>>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
92 }
93
94 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
95 fn derive_enumrust-analyzer cargo glib-macros 0.22.6 derive_enum().() {
96 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, glibrust-analyzer cargo glib 0.22.5 crate/::Enumrust-analyzer cargo glib-macros 0.22.2 Enum:)]
97 #[repr(u32)]
98 #[enum_type(name = "TestAnimalType")]
99 enum Animalrust-analyzer cargo glib-macros 0.22.6 Animal# {
100 Goatrust-analyzer cargo glib-macros 0.22.6 Animal#Goat#,
101 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Dog")]
102 Dogrust-analyzer cargo glib-macros 0.22.6 Animal#Dog#,
103 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Cat", nick = "chat")]
104 Catrust-analyzer cargo glib-macros 0.22.6 Animal#Cat# = 5,
105 Badgerrust-analyzer cargo glib-macros 0.22.6 Animal#Badger#,
106 }
107
108 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Goatrust-analyzer cargo glib-macros 0.22.6 Animal#Goat#.into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][IntoGlib]into_glib().(), 0);
109 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Dogrust-analyzer cargo glib-macros 0.22.6 Animal#Dog#.into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][IntoGlib]into_glib().(), 1);
110 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Catrust-analyzer cargo glib-macros 0.22.6 Animal#Cat#.into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][IntoGlib]into_glib().(), 5);
111
112 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][`FromGlib<i32>`]from_glib().(0) }, Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Goatrust-analyzer cargo glib-macros 0.22.6 Animal#Goat#);
113 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][`FromGlib<i32>`]from_glib().(1) }, Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Dogrust-analyzer cargo glib-macros 0.22.6 Animal#Dog#);
114 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[Animal][`FromGlib<i32>`]from_glib().(5) }, Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Catrust-analyzer cargo glib-macros 0.22.6 Animal#Cat#);
115
116 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Goatrust-analyzer cargo glib-macros 0.22.6 Animal#Goat#.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[Animal][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Animalrust-analyzer cargo glib-macros 0.22.6 Animal#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Goatrust-analyzer cargo glib-macros 0.22.6 Animal#Goat#));
117 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Dogrust-analyzer cargo glib-macros 0.22.6 Animal#Dog#.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[Animal][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Animalrust-analyzer cargo glib-macros 0.22.6 Animal#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Dogrust-analyzer cargo glib-macros 0.22.6 Animal#Dog#));
118 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Catrust-analyzer cargo glib-macros 0.22.6 Animal#Cat#.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[Animal][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Animalrust-analyzer cargo glib-macros 0.22.6 Animal#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::Catrust-analyzer cargo glib-macros 0.22.6 Animal#Cat#));
119
120 let t = Animalrust-analyzer cargo glib-macros 0.22.6 Animal#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[Animal][StaticType]static_type().();
121 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::ENUMrust-analyzer cargo glib 0.22.5 types/impl#[Type]ENUM.));
122 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "TestAnimalType");
123
124 let e = glibrust-analyzer cargo glib 0.22.5 crate/::EnumClassrust-analyzer cargo glib 0.22.5 enums/EnumClass#::with_typerust-analyzer cargo glib 0.22.5 enums/impl#[EnumClass]with_type().(t).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("EnumClass::new failed");
125 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[EnumClass]value().(0).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("EnumClass::get_value(0) failed");
126 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]name().(), "Goat");
127 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]nick().(), "goat");
128 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[EnumClass]value().(1).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("EnumClass::get_value(1) failed");
129 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]name().(), "The Dog");
130 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]nick().(), "dog");
131 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[EnumClass]value().(5).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("EnumClass::get_value(5) failed");
132 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]name().(), "The Cat");
133 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[EnumValue]nick().(), "chat");
134 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[EnumClass]value().(2), Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#);
135 }
136
137 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
138 fn derive_boxedrust-analyzer cargo glib-macros 0.22.6 derive_boxed().() {
139 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Boxedrust-analyzer cargo glib-macros 0.22.2 Boxed:)]
140 #[boxed_type(name = "MyBoxed")]
141 struct MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
142
143 let t = MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[MyBoxed][StaticType]static_type().();
144 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::BOXEDrust-analyzer cargo glib 0.22.5 types/impl#[Type]BOXED.));
145 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "MyBoxed");
146
147 let b = MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("abc"));
148 let v = b.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyBoxed][ToValue]to_value().();
149 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<&MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#>().unwrap());
150 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
151 }
152
153 #[allow(clippy::unnecessary_literal_unwrap)]
154 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
155 fn derive_boxed_nullablerust-analyzer cargo glib-macros 0.22.6 derive_boxed_nullable().() {
156 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Boxedrust-analyzer cargo glib-macros 0.22.2 Boxed:)]
157 #[boxed_type(name = "MyNullableBoxed", nullable)]
158 struct MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
159
160 let t = MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[MyNullableBoxed][StaticType]static_type().();
161 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::BOXEDrust-analyzer cargo glib 0.22.5 types/impl#[Type]BOXED.));
162 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "MyNullableBoxed");
163
164 let b = MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("abc"));
165 let v = b.to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyNullableBoxed][ToValue]to_value().();
166 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwrap().unwrap());
167 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
168
169 let b = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("def")));
170 let v = b.to_valuerust-analyzer cargo glib 0.22.5 value/impl#[`Option<T>`][ToValue]to_value().();
171 let b = b.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
172 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwrap().unwrap());
173 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
174
175 let b = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("def")));
176 let v = b.to_valuerust-analyzer cargo glib 0.22.5 value/impl#[`Option<T>`][ToValue]to_value().();
177 let b = b.unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().();
178 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(&b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwrap().unwrap());
179 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(b, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().());
180
181 let b: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#> = Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#;
182 let v = b.to_valuerust-analyzer cargo glib 0.22.5 value/impl#[`Option<T>`][ToValue]to_value().();
183 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<&MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwrap());
184 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, v.getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<MyNullableBoxedrust-analyzer cargo glib-macros 0.22.6 MyNullableBoxed#>>().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().());
185 }
186
187 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
188 fn boxed_transparentrust-analyzer cargo glib-macros 0.22.6 boxed_transparent().() {
189 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Boxedrust-analyzer cargo glib-macros 0.22.2 Boxed:)]
190 #[boxed_type(name = "MyBoxed")]
191 struct MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
192
193 let vec = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("abc")), MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("dfg"))];
194
195 // Slice requires TransparentType trait
196 let slice = Slicerust-analyzer cargo glib 0.22.5 collections/slice/Slice#::fromrust-analyzer cargo glib 0.22.5 collections/slice/impl#[`Slice<T>`][`From<Vec<T>>`]from().(vec);
197 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(slice.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(MyBoxedrust-analyzer cargo glib-macros 0.22.6 MyBoxed#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("dfg"))).as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().());
198 }
199
200 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
201 fn attr_flagsrust-analyzer cargo glib-macros 0.22.6 attr_flags().() {
202 #[glibrust-analyzer cargo glib 0.22.5 crate/::flagsrust-analyzer cargo glib-macros 0.22.2 flags:(name = "MyFlags")]
203 enum MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags# {
204 #[flags_value(name = "Flag A", nick = "nick-a")]
205 Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A. = 0b00000001,
206 #[flags_value(name = "Flag B")]
207 Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B. = 0b00000010,
208 #[flags_value(skip)]
209 ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB. = Selfrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). Selfrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(),
210 Crust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]C. = 0b00000100,
211 }
212
213 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(), 1);
214 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(), 2);
215 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(), 3);
216
217 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::emptyrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]empty().().into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][IntoGlib]into_glib().(), 0);
218 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A..into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][IntoGlib]into_glib().(), 1);
219 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B..into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][IntoGlib]into_glib().(), 2);
220 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB..into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][IntoGlib]into_glib().(), 3);
221
222 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][`FromGlib<u32>`]from_glib().(0) }, MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::emptyrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]empty().());
223 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][`FromGlib<u32>`]from_glib().(1) }, MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A.);
224 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][`FromGlib<u32>`]from_glib().(2) }, MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B.);
225 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(unsafe { MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::from_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][`FromGlib<u32>`]from_glib().(3) }, MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB.);
226
227 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(
228 MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::emptyrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]empty().().to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#>(),
229 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::emptyrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]empty().())
230 );
231 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A..to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A.));
232 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B..to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B.));
233 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB..to_valuerust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][ToValue]to_value().().getrust-analyzer cargo glib 0.22.5 value/impl#[Value]get().::<MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#>(), Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]AB.));
234
235 let t = MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::static_typerust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][StaticType]static_type().();
236 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(t.is_arust-analyzer cargo glib 0.22.5 types/impl#[Type]is_a().(glibrust-analyzer cargo glib 0.22.5 crate/::Typerust-analyzer cargo glib 0.22.5 types/Type#::FLAGSrust-analyzer cargo glib 0.22.5 types/impl#[Type]FLAGS.));
237 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(t.namerust-analyzer cargo glib 0.22.5 types/impl#[Type]name().(), "MyFlags");
238
239 let e = glibrust-analyzer cargo glib 0.22.5 crate/::FlagsClassrust-analyzer cargo glib 0.22.5 enums/FlagsClass#::with_typerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]with_type().(t).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("FlagsClass::new failed");
240 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value().(1).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("FlagsClass::get_value(1) failed");
241 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]name().(), "Flag A");
242 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]nick().(), "nick-a");
243 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value().(2).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("FlagsClass::get_value(2) failed");
244 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]name().(), "Flag B");
245 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]nick().(), "b");
246 let v = e.valuerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value().(4).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("FlagsClass::get_value(4) failed");
247 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]name().(), "C");
248 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(v.nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsValue]nick().(), "c");
249
250 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_name().("Flag A").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
251 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_name().("Flag B").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
252 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_name().("AB").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
253 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_namerust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_name().("C").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
254
255 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_nick().("nick-a").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
256 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_nick().("b").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
257 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_nick().("ab").is_nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_none().());
258 assertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/assert!!(e.value_by_nickrust-analyzer cargo glib 0.22.5 enums/impl#[FlagsClass]value_by_nick().("c").is_somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]is_some().());
259 }
260
261 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
262 fn attr_flags_with_defaultrust-analyzer cargo glib-macros 0.22.6 attr_flags_with_default().() {
263 #[glibrust-analyzer cargo glib 0.22.5 crate/::flagsrust-analyzer cargo glib-macros 0.22.2 flags:(name = "MyFlags")]
264 enum MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags# {
265 #[flags_value(name = "Flag A", nick = "nick-a")]
266 Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A. = 0b00000001,
267 #[default]
268 #[flags_value(name = "Flag B")]
269 Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B. = 0b00000010,
270 }
271
272 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Arust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]A..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(), 1);
273 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]bits().(), 2);
274 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::defaultrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][Default]default().(), MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::Brust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags]B.);
275 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(MyFlagsrust-analyzer cargo glib-macros 0.22.6 MyFlags#::defaultrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][Default]default().().into_glibrust-analyzer cargo glib-macros 0.22.6 impl#[MyFlags][IntoGlib]into_glib().(), 2);
276 }
277
278 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
279 fn subclassablerust-analyzer cargo glib-macros 0.22.6 subclassable().() {
280 mod foorust-analyzer cargo glib-macros 0.22.6 foo/ {
281 use glibrust-analyzer cargo glib 0.22.5 crate/::subclassrust-analyzer cargo glib 0.22.5 subclass/::preluderust-analyzer cargo glib 0.22.5 subclass/prelude/::*;
282
283 use superrust-analyzer cargo glib-macros 0.22.6 crate/::*;
284
285 mod imprust-analyzer cargo glib-macros 0.22.6 foo/imp/ {
286 use superrust-analyzer cargo glib-macros 0.22.6 foo/::*;
287
288 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
289 pub struct Foorust-analyzer cargo glib-macros 0.22.6 foo/imp/Foo# {}
290
291 #[glibrust-analyzer cargo glib 0.22.5 crate/::object_subclassrust-analyzer cargo glib-macros 0.22.2 object_subclass:]
292 impl ObjectSubclassrust-analyzer cargo glib 0.22.5 subclass/types/ObjectSubclass# for Foorust-analyzer cargo glib-macros 0.22.6 foo/imp/Foo# {
293 const NAMErust-analyzer cargo glib-macros 0.22.6 foo/imp/impl#[Foo][ObjectSubclass]NAME.: &'static str = "MyFoo";
294 type Typerust-analyzer cargo glib-macros 0.22.6 foo/imp/impl#[Foo][ObjectSubclass]Type# = superrust-analyzer cargo glib-macros 0.22.6 foo/::Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#;
295 }
296
297 impl ObjectImplrust-analyzer cargo glib 0.22.5 subclass/object/ObjectImpl# for Foorust-analyzer cargo glib-macros 0.22.6 foo/imp/Foo# {}
298
299 impl Foorust-analyzer cargo glib-macros 0.22.6 foo/imp/Foo# {
300 pub(superrust-analyzer cargo glib-macros 0.22.6 foo/) fn testrust-analyzer cargo glib-macros 0.22.6 foo/imp/impl#[Foo]test().(&self) {}
301 }
302 }
303
304 pub trait FooExtrust-analyzer cargo glib-macros 0.22.6 foo/FooExt#: IsArust-analyzer cargo glib 0.22.5 object/IsA#<Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#> + 'static {
305 fn testrust-analyzer cargo glib-macros 0.22.6 foo/FooExt#test().(&self) {
306 let imp = self.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().().upcast_refrust-analyzer cargo glib 0.22.5 object/Cast#upcast_ref().::<Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#>().imprust-analyzer cargo glib 0.22.5 subclass/types/impl#[T][ObjectSubclassIsExt]imp().();
307 imp.testrust-analyzer cargo glib-macros 0.22.6 foo/imp/impl#[Foo]test().();
308 }
309 }
310
311 impl<O: IsArust-analyzer cargo glib 0.22.5 object/IsA#<Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#>> FooExtrust-analyzer cargo glib-macros 0.22.6 foo/FooExt# for O {}
312
313 glibrust-analyzer cargo glib 0.22.5 crate/::wrapperrust-analyzer cargo glib 0.22.5 wrapper/wrapper!! {
314 pub struct Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#(ObjectSubclass<imprust-analyzer cargo glib-macros 0.22.6 foo/imp/::Foorust-analyzer cargo glib-macros 0.22.6 foo/imp/Foo#>);
315 }
316 }
317
318 use foorust-analyzer cargo glib-macros 0.22.6 foo/::FooExtrust-analyzer cargo glib-macros 0.22.6 foo/FooExt#;
319
320 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<foorust-analyzer cargo glib-macros 0.22.6 foo/::Foorust-analyzer cargo glib-macros 0.22.6 foo/Foo#>();
321 obj.testrust-analyzer cargo glib-macros 0.22.6 foo/FooExt#test().();
322 }
323
324 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
325 fn derive_variantrust-analyzer cargo glib-macros 0.22.6 derive_variant().() {
326 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
327 struct Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1# {
328 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant1#some_string.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#,
329 some_intrust-analyzer cargo glib-macros 0.22.6 Variant1#some_int.: i32,
330 }
331
332 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant1][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(si)");
333 let v = Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1# {
334 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant1#some_string.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("bar"),
335 some_intrust-analyzer cargo glib-macros 0.22.6 Variant1#some_int.: 2,
336 };
337 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant1][ToVariant]to_variant().();
338 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(si)");
339 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
340
341 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
342 struct Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2# {
343 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant2#some_string.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>,
344 some_intrust-analyzer cargo glib-macros 0.22.6 Variant2#some_int.: i32,
345 }
346
347 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant2][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(msi)");
348 let v = Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2# {
349 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant2#some_string.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("bar")),
350 some_intrust-analyzer cargo glib-macros 0.22.6 Variant2#some_int.: 2,
351 };
352 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant2][ToVariant]to_variant().();
353 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(msi)");
354 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
355
356 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
357 struct Variant3rust-analyzer cargo glib-macros 0.22.6 Variant3#(u32, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#);
358
359 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant3rust-analyzer cargo glib-macros 0.22.6 Variant3#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant3][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(us)");
360 let v = Variant3rust-analyzer cargo glib-macros 0.22.6 Variant3#(1, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::fromrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`From<&str>`]from().("foo"));
361 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant3][ToVariant]to_variant().();
362 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(us)");
363 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant3rust-analyzer cargo glib-macros 0.22.6 Variant3#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
364
365 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
366 struct Variant4rust-analyzer cargo glib-macros 0.22.6 Variant4#;
367
368 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant4rust-analyzer cargo glib-macros 0.22.6 Variant4#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant4][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "()");
369 let v = Variant4rust-analyzer cargo glib-macros 0.22.6 Variant4#;
370 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant4][ToVariant]to_variant().();
371 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "()");
372 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant4rust-analyzer cargo glib-macros 0.22.6 Variant4#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
373
374 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
375 struct Variant5rust-analyzer cargo glib-macros 0.22.6 Variant5#();
376
377 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant5rust-analyzer cargo glib-macros 0.22.6 Variant5#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant5][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "()");
378 let v = Variant5rust-analyzer cargo glib-macros 0.22.6 Variant5#();
379 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant5][ToVariant]to_variant().();
380 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "()");
381 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant5rust-analyzer cargo glib-macros 0.22.6 Variant5#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
382
383 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
384 enum Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6# {
385 Unitrust-analyzer cargo glib-macros 0.22.6 Variant6#Unit#,
386 Tuplerust-analyzer cargo glib-macros 0.22.6 Variant6#Tuple#(i32, Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1#),
387 Structrust-analyzer cargo glib-macros 0.22.6 Variant6#Struct# { idrust-analyzer cargo glib-macros 0.22.6 Variant6#Struct#id.: i64, datarust-analyzer cargo glib-macros 0.22.6 Variant6#Struct#data.: Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2# },
388 }
389
390 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant6][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(sv)");
391 let v = Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#::Unitrust-analyzer cargo glib-macros 0.22.6 Variant6#Unit#;
392 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant6][ToVariant]to_variant().();
393 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(sv)");
394 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
395 let v = Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#::Tuplerust-analyzer cargo glib-macros 0.22.6 Variant6#Tuple#(
396 5,
397 Variant1rust-analyzer cargo glib-macros 0.22.6 Variant1# {
398 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant1#some_string.: "abc".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().(),
399 some_intrust-analyzer cargo glib-macros 0.22.6 Variant1#some_int.: 77,
400 },
401 );
402 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant6][ToVariant]to_variant().();
403 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(sv)");
404 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
405 let v = Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#::Structrust-analyzer cargo glib-macros 0.22.6 Variant6#Struct# {
406 idrust-analyzer cargo glib-macros 0.22.6 Variant6#Struct#id.: 299,
407 datarust-analyzer cargo glib-macros 0.22.6 Variant6#Struct#data.: Variant2rust-analyzer cargo glib-macros 0.22.6 Variant2# {
408 some_stringrust-analyzer cargo glib-macros 0.22.6 Variant2#some_string.: Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#("abcdef".intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()),
409 some_intrust-analyzer cargo glib-macros 0.22.6 Variant2#some_int.: 300,
410 },
411 };
412 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant6][ToVariant]to_variant().();
413 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(sv)");
414 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant6rust-analyzer cargo glib-macros 0.22.6 Variant6#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
415
416 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
417 #[variant_enum(repr)]
418 #[repr(u32)]
419 enum Variant7rust-analyzer cargo glib-macros 0.22.6 Variant7# {
420 Unitrust-analyzer cargo glib-macros 0.22.6 Variant7#Unit#,
421 Tuplerust-analyzer cargo glib-macros 0.22.6 Variant7#Tuple#(i32, Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#),
422 Structrust-analyzer cargo glib-macros 0.22.6 Variant7#Struct# { idrust-analyzer cargo glib-macros 0.22.6 Variant7#Struct#id.: i64, datarust-analyzer cargo glib-macros 0.22.6 Variant7#Struct#data.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<u8> },
423 }
424
425 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant7rust-analyzer cargo glib-macros 0.22.6 Variant7#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant7][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(uv)");
426 let v = Variant7rust-analyzer cargo glib-macros 0.22.6 Variant7#::Structrust-analyzer cargo glib-macros 0.22.6 Variant7#Struct# {
427 idrust-analyzer cargo glib-macros 0.22.6 Variant7#Struct#id.: 299,
428 datarust-analyzer cargo glib-macros 0.22.6 Variant7#Struct#data.: vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![55, 56, 57, 58],
429 };
430 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant7][ToVariant]to_variant().();
431 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "(uv)");
432 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant7rust-analyzer cargo glib-macros 0.22.6 Variant7#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
433
434 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:, glibrust-analyzer cargo glib 0.22.5 crate/::Enumrust-analyzer cargo glib-macros 0.22.2 Enum:)]
435 #[variant_enum(enum)]
436 #[repr(i32)]
437 #[enum_type(name = "Variant8")]
438 enum Variant8rust-analyzer cargo glib-macros 0.22.6 Variant8# {
439 Goatrust-analyzer cargo glib-macros 0.22.6 Variant8#Goat#,
440 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Dog")]
441 Dogrust-analyzer cargo glib-macros 0.22.6 Variant8#Dog#,
442 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Cat", nick = "chat")]
443 Catrust-analyzer cargo glib-macros 0.22.6 Variant8#Cat# = 5,
444 Badgerrust-analyzer cargo glib-macros 0.22.6 Variant8#Badger#,
445 }
446
447 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant8rust-analyzer cargo glib-macros 0.22.6 Variant8#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant8][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
448 let v = Variant8rust-analyzer cargo glib-macros 0.22.6 Variant8#::Catrust-analyzer cargo glib-macros 0.22.6 Variant8#Cat#;
449 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant8][ToVariant]to_variant().();
450 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
451 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "'chat'");
452 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant8rust-analyzer cargo glib-macros 0.22.6 Variant8#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
453
454 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:, glibrust-analyzer cargo glib 0.22.5 crate/::Enumrust-analyzer cargo glib-macros 0.22.2 Enum:)]
455 #[variant_enum(enum, repr)]
456 #[repr(i32)]
457 #[enum_type(name = "Variant9")]
458 enum Variant9rust-analyzer cargo glib-macros 0.22.6 Variant9# {
459 Goatrust-analyzer cargo glib-macros 0.22.6 Variant9#Goat#,
460 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Dog")]
461 Dogrust-analyzer cargo glib-macros 0.22.6 Variant9#Dog#,
462 #[enum_valuerust-analyzer cargo glib-macros 0.22.2 enum_value:(name = "The Cat", nick = "chat")]
463 Catrust-analyzer cargo glib-macros 0.22.6 Variant9#Cat# = 5,
464 Badgerrust-analyzer cargo glib-macros 0.22.6 Variant9#Badger#,
465 }
466
467 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant9rust-analyzer cargo glib-macros 0.22.6 Variant9#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant9][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "i");
468 let v = Variant9rust-analyzer cargo glib-macros 0.22.6 Variant9#::Badgerrust-analyzer cargo glib-macros 0.22.6 Variant9#Badger#;
469 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant9][ToVariant]to_variant().();
470 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "i");
471 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant9rust-analyzer cargo glib-macros 0.22.6 Variant9#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
472
473 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(glib::Variant)]
474 #[variant_enum(flags)]
475 #[glibrust-analyzer cargo glib 0.22.5 crate/::flagsrust-analyzer cargo glib-macros 0.22.2 flags:(name = "Variant10")]
476 enum Variant10rust-analyzer cargo glib-macros 0.22.6 Variant10# {
477 EMPTYrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]EMPTY. = 0,
478 #[flags_value(name = "Flag A", nick = "nick-a")]
479 Arust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]A. = 0b00000001,
480 #[flags_value(name = "Flag B")]
481 Brust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]B. = 0b00000010,
482 #[flags_value(skip)]
483 ABrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]AB. = Selfrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]::Arust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]A..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]bits().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). Selfrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]::Brust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]B..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]bits().(),
484 Crust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]C. = 0b00000100,
485 }
486
487 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant10rust-analyzer cargo glib-macros 0.22.6 Variant10#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant10][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
488 let v = Variant10rust-analyzer cargo glib-macros 0.22.6 Variant10#::ABrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10]AB.;
489 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant10][ToVariant]to_variant().();
490 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
491 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), "'nick-a|b'");
492 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant10rust-analyzer cargo glib-macros 0.22.6 Variant10#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
493
494 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(glib::Variant)]
495 #[variant_enum(flags, repr)]
496 #[glibrust-analyzer cargo glib 0.22.5 crate/::flagsrust-analyzer cargo glib-macros 0.22.2 flags:(name = "Variant11")]
497 enum Variant11rust-analyzer cargo glib-macros 0.22.6 Variant11# {
498 #[flags_value(name = "Flag A", nick = "nick-a")]
499 Arust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]A. = 0b00000001,
500 #[flags_value(name = "Flag B")]
501 Brust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]B. = 0b00000010,
502 #[flags_value(skip)]
503 ABrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]AB. = Selfrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]::Arust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]A..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]bits().() |rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[u32][`BitOr<Self>`]bitor(). Selfrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]::Brust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]B..bitsrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]bits().(),
504 Crust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]C. = 0b00000100,
505 }
506
507 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant11rust-analyzer cargo glib-macros 0.22.6 Variant11#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant11][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "u");
508 let v = Variant11rust-analyzer cargo glib-macros 0.22.6 Variant11#::Arust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]A. rust-analyzer cargo glib-macros 0.22.6 impl#[Variant11][`BitOr<Self>`]bitor().|rust-analyzer cargo glib-macros 0.22.6 impl#[Variant11][`BitOr<Self>`]bitor(). rust-analyzer cargo glib-macros 0.22.6 impl#[Variant11][`BitOr<Self>`]bitor().Variant11rust-analyzer cargo glib-macros 0.22.6 Variant11#::Crust-analyzer cargo glib-macros 0.22.6 impl#[Variant11]C.;
509 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant11][ToVariant]to_variant().();
510 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "u");
511 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant11rust-analyzer cargo glib-macros 0.22.6 Variant11#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
512
513 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
514 enum Variant12rust-analyzer cargo glib-macros 0.22.6 Variant12# {
515 Goatrust-analyzer cargo glib-macros 0.22.6 Variant12#Goat#,
516 Dogrust-analyzer cargo glib-macros 0.22.6 Variant12#Dog#,
517 Catrust-analyzer cargo glib-macros 0.22.6 Variant12#Cat# = 5,
518 Badgerrust-analyzer cargo glib-macros 0.22.6 Variant12#Badger#,
519 }
520
521 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant12rust-analyzer cargo glib-macros 0.22.6 Variant12#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant12][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
522 let v = Variant12rust-analyzer cargo glib-macros 0.22.6 Variant12#::Dogrust-analyzer cargo glib-macros 0.22.6 Variant12#Dog#;
523 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant12][ToVariant]to_variant().();
524 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "s");
525 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant12rust-analyzer cargo glib-macros 0.22.6 Variant12#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
526
527 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq:, Eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Eq:, Copyrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Copy:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, glibrust-analyzer cargo glib 0.22.5 crate/::Variantrust-analyzer cargo glib-macros 0.22.2 Variant:)]
528 #[variant_enum(repr)]
529 #[repr(u8)]
530 enum Variant13rust-analyzer cargo glib-macros 0.22.6 Variant13# {
531 Goatrust-analyzer cargo glib-macros 0.22.6 Variant13#Goat#,
532 Dogrust-analyzer cargo glib-macros 0.22.6 Variant13#Dog#,
533 Catrust-analyzer cargo glib-macros 0.22.6 Variant13#Cat# = 5,
534 Badgerrust-analyzer cargo glib-macros 0.22.6 Variant13#Badger#,
535 }
536
537 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(Variant13rust-analyzer cargo glib-macros 0.22.6 Variant13#::static_variant_typerust-analyzer cargo glib-macros 0.22.6 impl#[Variant13][StaticVariantType]static_variant_type().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "y");
538 let v = Variant13rust-analyzer cargo glib-macros 0.22.6 Variant13#::Badgerrust-analyzer cargo glib-macros 0.22.6 Variant13#Badger#;
539 let var = v.to_variantrust-analyzer cargo glib-macros 0.22.6 impl#[Variant13][ToVariant]to_variant().();
540 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.type_rust-analyzer cargo glib 0.22.5 variant/impl#[Variant]type_().().as_strrust-analyzer cargo glib 0.22.5 variant_type/impl#[VariantTy]as_str().(), "y");
541 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(var.getrust-analyzer cargo glib 0.22.5 variant/impl#[Variant]get().::<Variant13rust-analyzer cargo glib-macros 0.22.6 Variant13#>(), Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v));
542 }
543
544 #[testrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/test:]
545 fn closurerust-analyzer cargo glib-macros 0.22.6 closure().() {
546 let empty = glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|| {});
547 empty.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
548
549 let no_arg = glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|| 2i32);
550 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(no_arg.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<i32>(&[]), 2);
551
552 let add_1 = glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|x: i32| x +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). 1);
553 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(add_1.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<i32>(&[&3i32]), 4);
554
555 let concat_str = glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|s: &str| s.to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/impl#[str][ToOwned]to_owned().() +rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][`Add<&str>`]add(). " World");
556 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(concat_str.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#>(&[&"Hello"]), "Hello World");
557
558 let weak_test = {
559 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
560
561 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().(), 1);
562 let weak_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
563 #[watch]
564 obj,
565 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
566 );
567 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().(), 1);
568 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
569 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().(), 1);
570
571 weak_test
572 };
573 weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
574
575 {
576 trait TestExtrust-analyzer cargo glib-macros 0.22.6 TestExt# {
577 fn ref_count_in_closurerust-analyzer cargo glib-macros 0.22.6 TestExt#ref_count_in_closure().(&self) -> u32;
578 }
579
580 impl TestExtrust-analyzer cargo glib-macros 0.22.6 TestExt# for glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object# {
581 fn ref_count_in_closurerust-analyzer cargo glib-macros 0.22.6 impl#[`glib::Object`][TestExt]ref_count_in_closure().(&self) -> u32 {
582 let closure = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
583 #[watch(rename_to = obj)]
584 self,
585 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
586 );
587 closure.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[])
588 }
589 }
590
591 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
592 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.ref_count_in_closurerust-analyzer cargo glib-macros 0.22.6 impl#[`glib::Object`][TestExt]ref_count_in_closure().(), 2);
593 }
594
595 {
596 struct Arust-analyzer cargo glib-macros 0.22.6 A# {
597 objrust-analyzer cargo glib-macros 0.22.6 A#obj.: glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#,
598 }
599
600 impl Arust-analyzer cargo glib-macros 0.22.6 A# {
601 fn ref_count_in_closurerust-analyzer cargo glib-macros 0.22.6 impl#[A]ref_count_in_closure().(&self) -> u32 {
602 let closure = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
603 #[watch(rename_to = obj)]
604 self.objrust-analyzer cargo glib-macros 0.22.6 A#obj.,
605 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
606 );
607 closure.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[])
608 }
609 }
610
611 let a = Arust-analyzer cargo glib-macros 0.22.6 A# {
612 objrust-analyzer cargo glib-macros 0.22.6 A#obj.: glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>(),
613 };
614 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(a.ref_count_in_closurerust-analyzer cargo glib-macros 0.22.6 impl#[A]ref_count_in_closure().(), 2);
615 }
616
617 let strong_test = {
618 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
619
620 let strong_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
621 #[strong]
622 obj,
623 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
624 );
625 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(strong_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
626
627 strong_test
628 };
629 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(strong_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 1);
630
631 let weak_none_test = {
632 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
633
634 let weak_none_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
635 #[weak_allow_none]
636 obj,
637 move || { obj.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|o| o.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()).unwrap_or_defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or_default().() }
638 );
639 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_none_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
640
641 weak_none_test
642 };
643 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_none_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 0);
644
645 let weak_test_or_else = {
646 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
647
648 let weak_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
649 #[weak]
650 obj,
651 #[upgrade_or_else]
652 || 0,
653 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
654 );
655 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
656
657 weak_test
658 };
659 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test_or_else.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 0);
660
661 let weak_test_or = {
662 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
663
664 let weak_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
665 #[weak]
666 obj,
667 #[upgrade_or]
668 0,
669 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
670 );
671 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
672
673 weak_test
674 };
675 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test_or.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 0);
676
677 let weak_test_or_default = {
678 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
679
680 let weak_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
681 #[weak]
682 obj,
683 #[upgrade_or_default]
684 move || obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
685 );
686 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
687
688 weak_test
689 };
690 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(weak_test_or_default.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 0);
691
692 {
693 let ret = stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/impl#[`Rc<T>`]new().(stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/::Cellrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/Cell#::newrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]new().(0));
694 let weak_test_or_unit = {
695 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
696
697 let weak_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
698 #[weak]
699 obj,
700 #[strong]
701 ret,
702 move || {
703 ret.setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(obj.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().());
704 }
705 );
706 weak_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
707 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ret.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().(), 2);
708 ret.setrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]set().(0);
709
710 weak_test
711 };
712 weak_test_or_unit.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
713
714 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(ret.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cell/impl#[`Cell<T>`]get().(), 0);
715 }
716
717 {
718 let obj1 = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
719 let obj2 = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
720
721 let obj_arg_test =
722 glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(|a: glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#, b: glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#| { a.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). b.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().() });
723 let rc = obj_arg_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[&obj1, &obj2]);
724 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(rc, 6);
725
726 let alias_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
727 #[strong(rename_to = a)]
728 obj1,
729 #[strong]
730 obj2,
731 move || { a.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().() +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Add<Self>`]add(). obj2.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().() }
732 );
733 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(alias_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 4);
734 }
735
736 {
737 struct Arust-analyzer cargo glib-macros 0.22.6 A# {
738 arust-analyzer cargo glib-macros 0.22.6 A#a.: glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#,
739 }
740
741 let a = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#>();
742 let a_struct = Arust-analyzer cargo glib-macros 0.22.6 A# { arust-analyzer cargo glib-macros 0.22.6 A#a. };
743 let struct_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
744 #[strong(rename_to = a)]
745 a_struct.arust-analyzer cargo glib-macros 0.22.6 A#a.,
746 move || { a.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().() }
747 );
748 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(struct_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
749 }
750
751 {
752 use glibrust-analyzer cargo glib 0.22.5 crate/::{preluderust-analyzer cargo glib 0.22.5 prelude/::*, subclassrust-analyzer cargo glib 0.22.5 subclass/::preluderust-analyzer cargo glib 0.22.5 subclass/prelude/::*};
753
754 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
755 pub struct FooPrivaterust-analyzer cargo glib-macros 0.22.6 FooPrivate# {}
756
757 #[glibrust-analyzer cargo glib 0.22.5 crate/::object_subclassrust-analyzer cargo glib-macros 0.22.2 object_subclass:]
758 impl ObjectSubclassrust-analyzer cargo glib 0.22.5 subclass/types/ObjectSubclass# for FooPrivaterust-analyzer cargo glib-macros 0.22.6 FooPrivate# {
759 const NAMErust-analyzer cargo glib-macros 0.22.6 impl#[FooPrivate][ObjectSubclass]NAME.: &'static str = "MyFoo2";
760 type Typerust-analyzer cargo glib-macros 0.22.6 impl#[FooPrivate][ObjectSubclass]Type# = Foorust-analyzer cargo glib-macros 0.22.6 Foo#;
761 }
762
763 impl ObjectImplrust-analyzer cargo glib 0.22.5 subclass/object/ObjectImpl# for FooPrivaterust-analyzer cargo glib-macros 0.22.6 FooPrivate# {}
764
765 glibrust-analyzer cargo glib 0.22.5 crate/::wrapperrust-analyzer cargo glib 0.22.5 wrapper/wrapper!! {
766 pub struct Foorust-analyzer cargo glib-macros 0.22.6 Foo#(ObjectSubclass<FooPrivaterust-analyzer cargo glib-macros 0.22.6 FooPrivate#>);
767 }
768
769 impl Foorust-analyzer cargo glib-macros 0.22.6 Foo# {
770 fn my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().(&self) -> u32 {
771 self.ref_countrust-analyzer cargo glib 0.22.5 object/impl#[T][ObjectExt]ref_count().()
772 }
773 }
774
775 let cast_test = {
776 let f = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<Foorust-analyzer cargo glib-macros 0.22.6 Foo#>();
777
778 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().(), 1);
779 let cast_test = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
780 #[watch]
781 f,
782 move || f.my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().()
783 );
784 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().(), 1);
785 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(cast_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<u32>(&[]), 2);
786 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(f.my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().(), 1);
787
788 let f_ref = &f;
789 let _ = glibrust-analyzer cargo glib 0.22.5 crate/::closure_localrust-analyzer cargo glib-macros 0.22.2 closure_local!!(
790 #[watch]
791 f_ref,
792 move || f_ref.my_ref_countrust-analyzer cargo glib-macros 0.22.6 impl#[Foo]my_ref_count().()
793 );
794
795 cast_test
796 };
797 cast_test.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
798 }
799
800 {
801 use glibrust-analyzer cargo glib 0.22.5 crate/::subclassrust-analyzer cargo glib 0.22.5 subclass/::preluderust-analyzer cargo glib 0.22.5 subclass/prelude/::*;
802
803 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
804 pub struct SendObjectPrivaterust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate# {
805 valuerust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate#value.: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#<i32>,
806 }
807
808 #[glibrust-analyzer cargo glib 0.22.5 crate/::object_subclassrust-analyzer cargo glib-macros 0.22.2 object_subclass:]
809 impl ObjectSubclassrust-analyzer cargo glib 0.22.5 subclass/types/ObjectSubclass# for SendObjectPrivaterust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate# {
810 const NAMErust-analyzer cargo glib-macros 0.22.6 impl#[SendObjectPrivate][ObjectSubclass]NAME.: &'static str = "SendObject";
811 type Typerust-analyzer cargo glib-macros 0.22.6 impl#[SendObjectPrivate][ObjectSubclass]Type# = SendObjectrust-analyzer cargo glib-macros 0.22.6 SendObject#;
812 }
813
814 impl ObjectImplrust-analyzer cargo glib 0.22.5 subclass/object/ObjectImpl# for SendObjectPrivaterust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate# {}
815
816 glibrust-analyzer cargo glib 0.22.5 crate/::wrapperrust-analyzer cargo glib 0.22.5 wrapper/wrapper!! {
817 pub struct SendObjectrust-analyzer cargo glib-macros 0.22.6 SendObject#(ObjectSubclass<SendObjectPrivaterust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate#>);
818 }
819 impl SendObjectrust-analyzer cargo glib-macros 0.22.6 SendObject# {
820 fn valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]value().(&self) -> i32 {
821 *rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][Deref]deref().self.imprust-analyzer cargo glib 0.22.5 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().valuerust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate#value..lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().()
822 }
823 fn set_valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]set_value().(&self, v: i32) {
824 *rust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`MutexGuard<'_, T>`][DerefMut]deref_mut().self.imprust-analyzer cargo glib 0.22.5 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().valuerust-analyzer cargo glib-macros 0.22.6 SendObjectPrivate#value..lockrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/impl#[`Mutex<T>`]lock().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() = v;
825 }
826 }
827
828 let inc_by = {
829 let obj = glibrust-analyzer cargo glib 0.22.5 crate/::Objectrust-analyzer cargo glib 0.22.5 object/Object#::newrust-analyzer cargo glib 0.22.5 object/impl#[Object]new().::<SendObjectrust-analyzer cargo glib-macros 0.22.6 SendObject#>();
830 let obj = obj.imprust-analyzer cargo glib 0.22.5 subclass/types/impl#[T][ObjectSubclassIsExt]imp().().objrust-analyzer cargo glib 0.22.5 subclass/types/impl#[T][ObjectSubclassExt]obj().();
831 let inc_by = glibrust-analyzer cargo glib 0.22.5 crate/::closurerust-analyzer cargo glib-macros 0.22.2 closure!!(
832 #[watch]
833 obj,
834 move |x: i32| {
835 let old = obj.valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]value().();
836 obj.set_valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]set_value().(x +rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). old);
837 old
838 }
839 );
840 obj.set_valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]set_value().(42);
841 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]value().(), 42);
842 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(inc_by.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<i32>(&[&24i32]), 42);
843 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(obj.valuerust-analyzer cargo glib-macros 0.22.6 impl#[SendObject]value().(), 66);
844 inc_by
845 };
846 inc_by.invokerust-analyzer cargo glib 0.22.5 closure/impl#[RustClosure]invoke().::<()>(&[]);
847 }
848 }