diff options
| author | Ezra Shaw <ezrasure@outlook.com> | 2023-01-09 22:21:21 +1300 |
|---|---|---|
| committer | Ezra Shaw <ezrasure@outlook.com> | 2023-01-10 15:34:21 +1300 |
| commit | 203bbfa2f76090e51e237da1017de19497b36d0e (patch) | |
| tree | 992c6522701114e760923f95aa31e634d684d38b /library/alloc/src/string.rs | |
| parent | 3254bef9a79bd762b8cece2078abe168cb29ccb1 (diff) | |
| download | rust-203bbfa2f76090e51e237da1017de19497b36d0e.tar.gz rust-203bbfa2f76090e51e237da1017de19497b36d0e.zip | |
impl: specialize impl of `ToString` on `bool`
Diffstat (limited to 'library/alloc/src/string.rs')
| -rw-r--r-- | library/alloc/src/string.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/library/alloc/src/string.rs b/library/alloc/src/string.rs index 24f1b3a1c87..3118c7189a5 100644 --- a/library/alloc/src/string.rs +++ b/library/alloc/src/string.rs @@ -2549,6 +2549,15 @@ impl ToString for char { } #[cfg(not(no_global_oom_handling))] +#[stable(feature = "bool_to_string_specialization", since = "CURRENT_RUSTC_VERSION")] +impl ToString for bool { + #[inline] + fn to_string(&self) -> String { + String::from(if *self { "true" } else { "false" }) + } +} + +#[cfg(not(no_global_oom_handling))] #[stable(feature = "u8_to_string_specialization", since = "1.54.0")] impl ToString for u8 { #[inline] |
