Skip to content

Commit 203bbfa

Browse files
committedJan 10, 2023
impl: specialize impl of ToString on bool
1 parent 3254bef commit 203bbfa

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed
 

‎library/alloc/src/string.rs

+9
Original file line numberDiff line numberDiff line change
@@ -2548,6 +2548,15 @@ impl ToString for char {
25482548
}
25492549
}
25502550

2551+
#[cfg(not(no_global_oom_handling))]
2552+
#[stable(feature = "bool_to_string_specialization", since = "CURRENT_RUSTC_VERSION")]
2553+
impl ToString for bool {
2554+
#[inline]
2555+
fn to_string(&self) -> String {
2556+
String::from(if *self { "true" } else { "false" })
2557+
}
2558+
}
2559+
25512560
#[cfg(not(no_global_oom_handling))]
25522561
#[stable(feature = "u8_to_string_specialization", since = "1.54.0")]
25532562
impl ToString for u8 {

0 commit comments

Comments
 (0)
Please sign in to comment.