I'd like to use closures to make things a little more manageable.
What is my problem here?
I'd like to use closures to make things a little more manageable.
What is my problem here?
into_bytes
consumes the String
to give you back a Vec
, since you only have a reference you can't consume it, but as_bytes
is here for you.
You will get another error because you take &Vec<u8>
as argument (which you should never do) but you can fix it by using &[u8]
.
Out of curiosity, why should you never do that?
&Vec<T>
doesn't do anything useful that &[T]
can't do and using a slice allows to accept other types.
This stack overflow answer has an in-depth explanation.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.