Replies: 1 comment 2 replies
-
Hi! Although, I wonder if we could instead make it less magical with However, there are several problems. Uninlined error type (rustdoc issue)Suppose we use fn member<T: TryInto<U>>(self, value: T) -> Result<Builder<SetMember<S>>, <T as TryInto<U>>::Error>; But.. When you generate documentation for a such a method, rustdoc won't inline this Do we really need to have
|
Beta Was this translation helpful? Give feedback.
-
I recently wrote a
with
which usesTryInto
for a fallible conversion. This was doable, but seemed like something that was a bit boilerplate-y. In addition, I had to fix the error type to something known on the output side.I think this could be improved by an annotation; less boilerplate, and I think the output error type then can be set by the error of the
impl
in use (by adding a generic parameter to the setter).Example of what I currently do:
#[builder(with = |v: impl TryInto<MyValue, Error = impl Into<MyError>>| -> Result<_, MyError> { v.try_into().map_err(|e| e.into()) })]
How it could look:
#[builder(try_into)]
How it would look in terms of codegen:
Would this be worth doing?
Beta Was this translation helpful? Give feedback.
All reactions