You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By returning FromIterator you are forcing the function user, to collect the data into something (most likely something from alloc like String or Vec).
I would propose to change the bounds to IntoIterator<Item = char>, you could still collect it into for example a String value.encode_hex().collect::<String>();, but with the benefit of being able to loop though the entire thing without extra allocations.
For example #8 needs a wrapper type, that implements fmt::UpperHex, with the current definition you would have to write it like this
The problematic parts of code:
By returning
FromIterator
you are forcing the function user, to collect the data into something (most likely something fromalloc
likeString
orVec
).I would propose to change the bounds to
IntoIterator<Item = char>
, you could still collect it into for example aString
value.encode_hex().collect::<String>();
, but with the benefit of being able to loop though the entire thing without extra allocations.For example #8 needs a wrapper type, that implements
fmt::UpperHex
, with the current definition you would have to write it like thisAs you can see you have to create a temporary
String
, which would requirealloc
.If the trait would return
IntoIterator<Item = char>
you could do thiswhich does not allocate anywhere.
The text was updated successfully, but these errors were encountered: