Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Code shared from the Rust Playground
#![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
You can’t perform that action at this time.