Guest User

Untitled

a guest
May 22nd, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. enum HW {
  2. Hello(String)
  3. }
  4.  
  5. impl std::convert::From<&'static str> for HW {
  6. fn from(value: &'static str) -> Self {
  7. HW::Hello(String::from(value))
  8. }
  9. }
  10.  
  11. fn greets<I: Into<HW>>(hello: I){
  12. match hello.into() {
  13. HW::Hello(value) => println!("Hello, {}!", value)
  14. }
  15. }
  16.  
  17. fn main(){
  18. greets("world");
  19. //Is it possible to shortcut to something like this
  20. //greets("world");
  21. }
Add Comment
Please, Sign In to add comment