We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
str
1 parent 5b3cd39 commit 3155b31Copy full SHA for 3155b31
src/libcollections/string.rs
@@ -932,7 +932,7 @@ pub trait ToString {
932
fn to_string(&self) -> String;
933
}
934
935
-impl<T: fmt::String> ToString for T {
+impl<T: fmt::String + ?Sized> ToString for T {
936
fn to_string(&self) -> String {
937
use core::fmt::Writer;
938
let mut buf = String::new();
@@ -994,6 +994,12 @@ mod tests {
994
assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
995
996
997
+ #[test]
998
+ fn test_unsized_to_string() {
999
+ let s: &str = "abc";
1000
+ let _: String = (*s).to_string();
1001
+ }
1002
+
1003
#[test]
1004
fn test_from_utf8() {
1005
let xs = b"hello".to_vec();
0 commit comments