Skip to content

Instantly share code, notes, and snippets.

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