SHARE
TWEET

Untitled

a guest Jul 23rd, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #![allow(unused)]
  2.  
  3. use std::borrow::Cow;
  4. use std::borrow::ToOwned;
  5.  
  6. fn main() {
  7.  
  8.     let s = "sdfsf".to_string();
  9.     let cow: Cow<str> = Cow::Owned(s);
  10.  
  11.     // not own
  12.     let s2: String = cow.as_ref().into();
  13.    
  14.     let x: () = cow.as_ref();
  15.     let y: () = &cow;
  16.     let s4 = Into::<String>::into();
  17.    
  18.  
  19.     //println!("{}", &cow);
  20.  
  21.     // own
  22.     //let s3 = cow.into_owned();
  23.  
  24.     // cause error
  25.     // println!("{}", &cow);
  26.  
  27. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top