Skip to content

"Hello Tokio" step of tutorial and "into" method #3525

Answered by barkanido
mvolkmann asked this question in Q&A
Discussion options

You must be logged in to vote

the set fn is of type

pub async fn set(&mut self, key: &str, value: Bytes) -> crate::Result<()>

which means that the &str "world" is converted into Bytes using into(). into is automatically generated by the compiler because the Bytes struct is implementing several from methods. see here.

This is the idiomatic way for type conversions in Rust. For more information about how it works, you can read about the From trait.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by Darksonn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants