Skip to content

Commit 9cdb2d3

Browse files
committed
Auto merge of #86655 - jonas-schievink:const-arguments-as-str, r=kennytm
Make `fmt::Arguments::as_str` unstably const Motivation: mostly to move "panic!() in const contexts" forward, making use of `as_str` was mentioned in #85194 (comment) and seems like the simplest way forward.
2 parents 49ba936 + b3fbfe4 commit 9cdb2d3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/fmt/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,8 +444,9 @@ impl<'a> Arguments<'a> {
444444
/// assert_eq!(format_args!("{}", 1).as_str(), None);
445445
/// ```
446446
#[stable(feature = "fmt_as_str", since = "1.52.0")]
447+
#[rustc_const_unstable(feature = "const_arguments_as_str", issue = "none")]
447448
#[inline]
448-
pub fn as_str(&self) -> Option<&'static str> {
449+
pub const fn as_str(&self) -> Option<&'static str> {
449450
match (self.pieces, self.args) {
450451
([], []) => Some(""),
451452
([s], []) => Some(s),

0 commit comments

Comments
 (0)