Created
July 11, 2019 20:48
-
-
Save rust-play/aaeafdce3121431d26f21f9c7b0cd438 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![allow(unused)] | |
use std::borrow::Cow; | |
use std::borrow::ToOwned; | |
fn main() { | |
let s = "sdfsf".to_string(); | |
let cow: Cow<str> = Cow::Owned(s); | |
// not own | |
let s2: String = cow.as_ref().into(); | |
let x: () = cow.as_ref(); | |
let y: () = &cow; | |
let s4 = Into::<String>::into(); | |
//println!("{}", &cow); | |
// own | |
//let s3 = cow.into_owned(); | |
// cause error | |
// println!("{}", &cow); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment