Currently gir, would generate AsRef<T> for fundamental types as a replacement of IsA<T> that is used for objects/interfaces. The problem with using AsRef<T> is it causes problems when the param is passed by value instead of by reference, so having a still generic Option<impl AsRef<T>> would mean having to clone the param before calling into_glib_ptr()
That is sub-optimal and we should probably avoid using AsRef here; maybe an alternative would be to allow configuring a trait to be used for a fundamental type and it sub-types. For example fundamental_trait = "IsExpression or something like that.
Currently gir, would generate
AsRef<T>
for fundamental types as a replacement ofIsA<T>
that is used for objects/interfaces. The problem with usingAsRef<T>
is it causes problems when the param is passed by value instead of by reference, so having a still genericOption<impl AsRef<T>>
would mean having to clone the param before callinginto_glib_ptr()
That is sub-optimal and we should probably avoid using
AsRef
here; maybe an alternative would be to allow configuring a trait to be used for a fundamental type and it sub-types. For examplefundamental_trait = "IsExpression
or something like that.Needs more thinking though. Details can be found at https://github.com/gtk-rs/gir/pull/1413/files#r1044662046