Skip to content

Accessing str member of Member #324

Answered by diwic
hpux735 asked this question in Q&A
Mar 26, 2021 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

As seen in the documentation, Member has a Deref<Target=str>, which means that you for the most part can use a &Member as if it were a &str. Example:

let m = myMessage.member()?;
let myStr: &str = &m; 

Or you can just use any str method on the member directly, like:

let m = myMessage.member()?;
let myStr = m.to_lowercase(); 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@hpux735
Comment options

Answer selected by hpux735
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