Created
July 11, 2019 20:48
-
-
Save rust-play/e1116c8f214be1e482adc792c4222db3 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 s4 = Into::<String>::into(cow.as_ref()); | |
//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