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(hello: HW){
- match hello {
- HW::Hello(value) => println!("Hello, {}!", value)
- }
- }
- fn main(){
- greets("world".into());
- //Is it possible to shortcut to something like this
- //greets("world");
- }
Add Comment
Please, Sign In to add comment