blob: b786296489d281111ba4aa0599c8201a3ba28c31 [file] [log] [blame]
{
"test": {
"file": "test_tooltip_std.rs",
"line": 15,
"col": 17
},
"data": {
"Ok": [
{
"language": "rust",
"value": "src/liballoc/string.rs"
},
"https://doc.rust-lang.org/nightly/alloc/string/",
"A UTF-8 encoded, growable string.\n\nThis module contains the [`String`] type, a trait for converting\n[`ToString`]s, and several error types that may result from working with\n[`String`]s.\n\n[`ToString`]: trait.ToString.html\n\n# Examples\n\nThere are multiple ways to create a new [`String`] from a string literal:\n\n```rust\nlet s = \"Hello\".to_string();\n\nlet s = String::from(\"world\");\nlet s: String = \"also this\".into();\n```\n\nYou can create a new [`String`] from an existing one by concatenating with\n`+`:\n\n[`String`]: struct.String.html\n\n```rust\nlet s = \"Hello\".to_string();\n\nlet message = s + \" world!\";\n```\n\nIf you have a vector of valid UTF-8 bytes, you can make a [`String`] out of\nit. You can do the reverse too.\n\n```rust\nlet sparkle_heart = vec![240, 159, 146, 150];\n\n// We know these bytes are valid, so we'll use `unwrap()`.\nlet sparkle_heart = String::from_utf8(sparkle_heart).unwrap();\n\nassert_eq!(\"💖\", sparkle_heart);\n\nlet bytes = sparkle_heart.into_bytes();\n\nassert_eq!(bytes, [240, 159, 146, 150]);\n```"
]
}
}