| 1 | // Take a look at the license at the top of the repository in the LICENSE file. |
| 2 | |
| 3 | use quoterust-analyzer cargo quote 1.0.44 crate/::quoterust-analyzer cargo quote 1.0.44 quote!; |
| 4 | use synrust-analyzer cargo syn 2.0.117 crate/::{Tokenrust-analyzer cargo syn 2.0.117 token/Token!, parserust-analyzer cargo syn 2.0.117 parse/::Parserust-analyzer cargo syn 2.0.117 parse/Parse#}; |
| 5 | |
| 6 | use craterust-analyzer cargo glib-macros 0.22.6 crate/::utilsrust-analyzer cargo glib-macros 0.22.6 utils/::crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().; |
| 7 | |
| 8 | #[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:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:)] |
| 9 | enum DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode# { |
| 10 | Fromrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#From#, |
| 11 | #[defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/default:] |
| 12 | Privaterust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#Private#, |
| 13 | } |
| 14 | |
| 15 | pub struct ValueDelegateInputrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput# { |
| 16 | delegated_tyrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#delegated_ty.: synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#, |
| 17 | identrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#ident.: synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident#, |
| 18 | moderust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#mode.: DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#, |
| 19 | nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#nullable.: bool, |
| 20 | } |
| 21 | |
| 22 | enum Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg# { |
| 23 | FromPathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#FromPath#(synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#), |
| 24 | Nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#Nullable#, |
| 25 | } |
| 26 | |
| 27 | impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg# { |
| 28 | fn parserust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[Arg][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[Arg][Parse]> { |
| 29 | let argname: synrust-analyzer cargo syn 2.0.117 crate/::Identrust-analyzer cargo proc-macro2 1.0.106 Ident# = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 30 | if argname rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq()."nullable" { |
| 31 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#::Nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#Nullable#) |
| 32 | } else if argname rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq().==rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq(). rust-analyzer cargo proc-macro2 1.0.106 impl#[Ident][`PartialEq<T>`]eq()."from" { |
| 33 | let _eq: Tokenrust-analyzer cargo syn 2.0.117 token/Token!![=] = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 34 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#::FromPathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#FromPath#(input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)) |
| 35 | } else { |
| 36 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().( |
| 37 | input.spanrust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]span().(), |
| 38 | "expected `nullable` or `from`", |
| 39 | )) |
| 40 | } |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | #[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:)] |
| 45 | struct Argsrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args# { |
| 46 | nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#nullable.: bool, |
| 47 | from_pathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#from_path.: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<synrust-analyzer cargo syn 2.0.117 crate/::Pathrust-analyzer cargo syn 2.0.117 path/Path#>, |
| 48 | } |
| 49 | |
| 50 | impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for Argsrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args# { |
| 51 | fn parserust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[Args][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[Args][Parse]> { |
| 52 | let args = synrust-analyzer cargo syn 2.0.117 crate/::punctuatedrust-analyzer cargo syn 2.0.117 punctuated/::Punctuatedrust-analyzer cargo syn 2.0.117 punctuated/Punctuated#::<Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#, Tokenrust-analyzer cargo syn 2.0.117 token/Token!![,]>::parse_terminatedrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]parse_terminated().(input)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 53 | let mut this = Argsrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#::defaultrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[Args][Default]default().(); |
| 54 | for a in args { |
| 55 | match a { |
| 56 | Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#::FromPathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#FromPath#(p) => this.from_pathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#from_path. = Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p), |
| 57 | Argrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#::Nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Arg#Nullable# => this.nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#nullable. = true, |
| 58 | } |
| 59 | } |
| 60 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(this) |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | impl Parserust-analyzer cargo syn 2.0.117 parse/Parse# for ValueDelegateInputrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput# { |
| 65 | fn parserust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[ValueDelegateInput][Parse]parse().(input: synrust-analyzer cargo syn 2.0.117 crate/::parserust-analyzer cargo syn 2.0.117 parse/::ParseStreamrust-analyzer cargo syn 2.0.117 parse/ParseStream#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<Selfrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl#[ValueDelegateInput][Parse]> { |
| 66 | let derive_input: synrust-analyzer cargo syn 2.0.117 crate/::DeriveInputrust-analyzer cargo syn 2.0.117 derive/DeriveInput# = input.parserust-analyzer cargo syn 2.0.117 parse/impl#[`ParseBuffer<'a>`]parse().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 67 | let args: Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Argsrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#> = if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(attr) = derive_input |
| 68 | .attrsrust-analyzer cargo syn 2.0.117 derive/DeriveInput#attrs. |
| 69 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 70 | .findrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/iter/impl#[`Iter<'a, T>`][Iterator]find().(|x| x.pathrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]path().().is_identrust-analyzer cargo syn 2.0.117 path/impl#[Path]is_ident().("value_delegate")) |
| 71 | { |
| 72 | let args: Argsrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args# = attr.parse_argsrust-analyzer cargo syn 2.0.117 attr/impl#[Attribute]parse_args().()?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 73 | Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(args) |
| 74 | } else { |
| 75 | Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# |
| 76 | }; |
| 77 | |
| 78 | let (delegated_ty, mode) = |
| 79 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path) = args.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|a| a.from_pathrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#from_path..as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]as_ref().()) { |
| 80 | (Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(path.clonerust-analyzer cargo syn 2.0.117 gen/clone/impl#[`crate::Path`][Clone]clone().()), DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Fromrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#From#) |
| 81 | } else { |
| 82 | let path = match derive_input.datarust-analyzer cargo syn 2.0.117 derive/DeriveInput#data. { |
| 83 | synrust-analyzer cargo syn 2.0.117 crate/::Datarust-analyzer cargo syn 2.0.117 derive/Data#::Structrust-analyzer cargo syn 2.0.117 derive/Data#Struct#(s) => match s.fieldsrust-analyzer cargo syn 2.0.117 derive/DataStruct#fields. { |
| 84 | synrust-analyzer cargo syn 2.0.117 crate/::Fieldsrust-analyzer cargo syn 2.0.117 data/Fields#::Unnamedrust-analyzer cargo syn 2.0.117 data/Fields#Unnamed#(fields) if fields.unnamedrust-analyzer cargo syn 2.0.117 data/FieldsUnnamed#unnamed..iterrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`]iter().().countrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#count().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1 => { |
| 85 | fields.unnamedrust-analyzer cargo syn 2.0.117 data/FieldsUnnamed#unnamed..into_iterrust-analyzer cargo syn 2.0.117 punctuated/impl#[`Punctuated<T, P>`][IntoIterator]into_iter().().nextrust-analyzer cargo syn 2.0.117 punctuated/impl#[`IntoIter<T>`][Iterator]next().().and_thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]and_then().(|x| match x.tyrust-analyzer cargo syn 2.0.117 data/Field#ty. { |
| 86 | synrust-analyzer cargo syn 2.0.117 crate/::Typerust-analyzer cargo syn 2.0.117 ty/Type#::Pathrust-analyzer cargo syn 2.0.117 ty/Type#Path#(p) => Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(p.pathrust-analyzer cargo syn 2.0.117 ty/TypePath#path.), |
| 87 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 88 | }) |
| 89 | } |
| 90 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 91 | }, |
| 92 | _ => Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None#, |
| 93 | }; |
| 94 | (path, DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Privaterust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#Private#) |
| 95 | }; |
| 96 | let delegated_ty = delegated_ty.ok_or_elserust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]ok_or_else().(|| { |
| 97 | synrust-analyzer cargo syn 2.0.117 crate/::Errorrust-analyzer cargo syn 2.0.117 error/Error#::newrust-analyzer cargo syn 2.0.117 error/impl#[Error]new().( |
| 98 | derive_input.identrust-analyzer cargo syn 2.0.117 derive/DeriveInput#ident..spanrust-analyzer cargo proc-macro2 1.0.106 impl#[Ident]span().(), |
| 99 | "Unless `derive(ValueDelegate)` is used over a newtype with 1 field, \ |
| 100 | the delegated type must be specified using \ |
| 101 | #[value_delegate(from = chosen_type)]", |
| 102 | ) |
| 103 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 104 | |
| 105 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(ValueDelegateInputrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput# { |
| 106 | delegated_tyrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#delegated_ty., |
| 107 | identrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#ident.: derive_input.identrust-analyzer cargo syn 2.0.117 derive/DeriveInput#ident., |
| 108 | moderust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#mode., |
| 109 | nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#nullable.: args.maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|a| a.nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/Args#nullable.).unwrap_orrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap_or().(false), |
| 110 | }) |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | pub fn impl_value_delegaterust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/impl_value_delegate().(input: ValueDelegateInputrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#) -> synrust-analyzer cargo syn 2.0.117 crate/::Resultrust-analyzer cargo syn 2.0.117 error/Result#<proc_macrorust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro crate/::TokenStreamrust-analyzer cargo proc_macro https://github.com/rust-lang/rust/library/proc_macro TokenStream#> { |
| 115 | let ValueDelegateInputrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput# { |
| 116 | delegated_tyrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#delegated_ty., |
| 117 | identrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#ident., |
| 118 | moderust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#mode., |
| 119 | nullablerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/ValueDelegateInput#nullable., |
| 120 | .. |
| 121 | } = &input; |
| 122 | let crate_ident = crate_ident_newrust-analyzer cargo glib-macros 0.22.6 utils/crate_ident_new().(); |
| 123 | |
| 124 | // this must be called in a context where `this` is defined. |
| 125 | let delegate_value = match mode { |
| 126 | DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Fromrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#From# => { |
| 127 | quoterust-analyzer cargo quote 1.0.44 quote!!(<#delegated_ty as std::convert::From<_>>::from(this)) |
| 128 | } |
| 129 | DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Privaterust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#Private# => quoterust-analyzer cargo quote 1.0.44 quote!!(this.0), |
| 130 | }; |
| 131 | |
| 132 | let to_value_optional = nullable.thenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core bool/impl#[bool]then().(|| { |
| 133 | quoterust-analyzer cargo quote 1.0.44 quote!! { |
| 134 | impl #crate_ident::value::ToValueOptional for #ident { |
| 135 | fn to_value_optional(s: ::core::option::Option<&Self>) -> #crate_ident::value::Value { |
| 136 | if let ::core::option::Option::Some(this) = s { |
| 137 | #crate_ident::value::ToValue::to_value(&::core::option::Option::Some(&#delegate_value)) |
| 138 | } else { |
| 139 | #crate_ident::value::ToValueOptional::to_value_optional(::core::option::Option::None::<&#delegated_ty>) |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | }); |
| 145 | |
| 146 | let from_value = match mode { |
| 147 | DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Fromrust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#From# => { |
| 148 | quoterust-analyzer cargo quote 1.0.44 quote!!(#ident::from(<#delegated_ty as #crate_ident::value::FromValue<'a>>::from_value(value))) |
| 149 | } |
| 150 | DeriveModerust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#::Privaterust-analyzer cargo glib-macros 0.22.6 value_delegate_derive/DeriveMode#Private# => { |
| 151 | quoterust-analyzer cargo quote 1.0.44 quote!!(#ident(<#delegated_ty as #crate_ident::value::FromValue<'a>>::from_value(value))) |
| 152 | } |
| 153 | }; |
| 154 | |
| 155 | let res = quoterust-analyzer cargo quote 1.0.44 quote!! { |
| 156 | impl #crate_ident::prelude::StaticType for #ident { |
| 157 | fn static_type() -> glib::types::Type { |
| 158 | <#delegated_ty as #crate_ident::prelude::StaticType>::static_type() |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | impl #crate_ident::value::ToValue for #ident { |
| 163 | fn to_value(&self) -> #crate_ident::value::Value { |
| 164 | let this = self; |
| 165 | #crate_ident::value::ToValue::to_value(&#delegate_value) |
| 166 | } |
| 167 | fn value_type(&self) -> #crate_ident::types::Type { |
| 168 | let this = self; |
| 169 | #crate_ident::value::ToValue::value_type(&#delegate_value) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | impl From<#ident> for #crate_ident::value::Value { |
| 174 | fn from(this: #ident) -> Self { |
| 175 | #crate_ident::value::Value::from(#delegate_value) |
| 176 | } |
| 177 | } |
| 178 | |
| 179 | #to_value_optional |
| 180 | |
| 181 | unsafe impl<'a> #crate_ident::value::FromValue<'a> for #ident { |
| 182 | type Checker = <#delegated_ty as #crate_ident::value::FromValue<'a>>::Checker; |
| 183 | |
| 184 | unsafe fn from_value(value: &'a #crate_ident::value::Value) -> Self { |
| 185 | #from_value |
| 186 | } |
| 187 | } |
| 188 | |
| 189 | impl #crate_ident::HasParamSpec for #ident { |
| 190 | type ParamSpec = <#delegated_ty as #crate_ident::HasParamSpec>::ParamSpec; |
| 191 | type SetValue = Self; |
| 192 | type BuilderFn = <#delegated_ty as #crate_ident::HasParamSpec>::BuilderFn; |
| 193 | |
| 194 | fn param_spec_builder() -> Self::BuilderFn { |
| 195 | <#delegated_ty as #crate_ident::prelude::HasParamSpec>::param_spec_builder() |
| 196 | } |
| 197 | } |
| 198 | }; |
| 199 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(res.intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().()) |
| 200 | } |