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
Is your feature request related to a problem? Please describe.
I have multiple StyledContent<D> object with different D. I want to convert them all to StyledContent<Cow<'a, str>>. Since content is a private field and content(&self) -> &D returns a reference, i cannot move the content out of the struct in order to convert them.
Describe the solution you'd like
Add an into_content(self) -> D method that moves the content out of the struct. This would allow implementing something like this:
The workaround with Clone works, but involves cloning the value unnecessarily and introduced an additional trait bound.
Destructuring is not possible, since the fields are private.
Of course I could also just call to_string() on the StyledContent and use these instead (and convert them into a StyledContent<Cow<'a, str>>). However, this seems hacky and I still need access to the unstyled content later, so this is not an option (because then I would need to strip the style later.
Additional context
n/a
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
I have multiple
StyledContent<D>
object with differentD
. I want to convert them all toStyledContent<Cow<'a, str>>
. Sincecontent
is a private field andcontent(&self) -> &D
returns a reference, i cannot move the content out of the struct in order to convert them.My current workaround involves cloning the value:
Describe the solution you'd like
Add an
into_content(self) -> D
method that moves the content out of the struct. This would allow implementing something like this:Describe alternatives you've considered if any
Clone
works, but involves cloning the value unnecessarily and introduced an additional trait bound.to_string()
on theStyledContent
and use these instead (and convert them into aStyledContent<Cow<'a, str>>
). However, this seems hacky and I still need access to the unstyled content later, so this is not an option (because then I would need to strip the style later.Additional context
n/a
The text was updated successfully, but these errors were encountered: