Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- enum HW {
- Hello(String)
- }
- impl std::convert::From<&'static str> for HW {
- fn from(value: &'static str) -> Self {
- HW::Hello(String::from(value))
- }
- }
- fn greets<I: Into<HW>>(hello: I){
- match hello.into() {
- HW::Hello(value) => println!("Hello, {}!", value)
- }
- }
- fn main(){
- greets("world");
- //Is it possible to shortcut to something like this
- //greets("world");
- }
Add Comment
Please, Sign In to add comment