Skip to content

Commit 2f99a41

Browse files
committed
auto merge of #20744 : huonw/rust/fix-string-slicing, r=pnkfelix
2 parents 5364c48 + 3155b31 commit 2f99a41

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libcollections/string.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -932,7 +932,7 @@ pub trait ToString {
932932
fn to_string(&self) -> String;
933933
}
934934

935-
impl<T: fmt::String> ToString for T {
935+
impl<T: fmt::String + ?Sized> ToString for T {
936936
fn to_string(&self) -> String {
937937
use core::fmt::Writer;
938938
let mut buf = String::new();
@@ -994,6 +994,12 @@ mod tests {
994994
assert_eq!(owned.as_ref().map(|s| s.as_slice()), Some("string"));
995995
}
996996

997+
#[test]
998+
fn test_unsized_to_string() {
999+
let s: &str = "abc";
1000+
let _: String = (*s).to_string();
1001+
}
1002+
9971003
#[test]
9981004
fn test_from_utf8() {
9991005
let xs = b"hello".to_vec();

0 commit comments

Comments
 (0)