about summary refs log tree commit diff
path: root/src/liballoc/string.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2020-06-18 01:36:43 +0200
committerMatthias Krüger <matthias.krueger@famsik.de>2020-06-18 04:58:08 +0200
commit1d0378c454de72ddcfc08bcc105744923ef2d4d4 (patch)
treef82fffd42199843ab65f3e0e5ccb2001a9e12d14 /src/liballoc/string.rs
parent2935d294ff862fdf96578d0cbbdc289e8e7ba81c (diff)
downloadrust-1d0378c454de72ddcfc08bcc105744923ef2d4d4.tar.gz
rust-1d0378c454de72ddcfc08bcc105744923ef2d4d4.zip
impl From<char> for String
This allows us to write

fn char_to_string() -> String {
    'a'.into()
}

which was not possible before.
Diffstat (limited to 'src/liballoc/string.rs')
-rw-r--r--src/liballoc/string.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/liballoc/string.rs b/src/liballoc/string.rs
index 0378ff5362a..cf86ba055b8 100644
--- a/src/liballoc/string.rs
+++ b/src/liballoc/string.rs
@@ -2508,3 +2508,11 @@ impl DoubleEndedIterator for Drain<'_> {
 
 #[stable(feature = "fused", since = "1.26.0")]
 impl FusedIterator for Drain<'_> {}
+
+#[stable(feature = "from_char_for_string", since = "1.46.0")]
+impl From<char> for String {
+    #[inline]
+    fn from(c: char) -> Self {
+        c.to_string()
+    }
+}