Rename Arguments::as_const_str
to as_statically_known_str
While `const` has a particular meaning about language guarantees, here we need a fuzzier notion like whether constant propagation was effective, and `statically_known` is the best term we have for now.
This commit is contained in:
parent
2f090c30dd
commit
b67ad8f626
@ -201,7 +201,7 @@ pub trait Write {
|
|||||||
impl<W: Write + ?Sized> SpecWriteFmt for &mut W {
|
impl<W: Write + ?Sized> SpecWriteFmt for &mut W {
|
||||||
#[inline]
|
#[inline]
|
||||||
default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {
|
default fn spec_write_fmt(mut self, args: Arguments<'_>) -> Result {
|
||||||
if let Some(s) = args.as_const_str() {
|
if let Some(s) = args.as_statically_known_str() {
|
||||||
self.write_str(s)
|
self.write_str(s)
|
||||||
} else {
|
} else {
|
||||||
write(&mut self, args)
|
write(&mut self, args)
|
||||||
@ -212,7 +212,7 @@ pub trait Write {
|
|||||||
impl<W: Write> SpecWriteFmt for &mut W {
|
impl<W: Write> SpecWriteFmt for &mut W {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn spec_write_fmt(self, args: Arguments<'_>) -> Result {
|
fn spec_write_fmt(self, args: Arguments<'_>) -> Result {
|
||||||
if let Some(s) = args.as_const_str() {
|
if let Some(s) = args.as_statically_known_str() {
|
||||||
self.write_str(s)
|
self.write_str(s)
|
||||||
} else {
|
} else {
|
||||||
write(self, args)
|
write(self, args)
|
||||||
@ -442,7 +442,7 @@ impl<'a> Arguments<'a> {
|
|||||||
/// Same as [`Arguments::as_str`], but will only return `Some(s)` if it can be determined at compile time.
|
/// Same as [`Arguments::as_str`], but will only return `Some(s)` if it can be determined at compile time.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn as_const_str(&self) -> Option<&'static str> {
|
fn as_statically_known_str(&self) -> Option<&'static str> {
|
||||||
let s = self.as_str();
|
let s = self.as_str();
|
||||||
if core::intrinsics::is_val_statically_known(s.is_some()) { s } else { None }
|
if core::intrinsics::is_val_statically_known(s.is_some()) { s } else { None }
|
||||||
}
|
}
|
||||||
@ -1617,7 +1617,11 @@ impl<'a> Formatter<'a> {
|
|||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result {
|
pub fn write_fmt(&mut self, fmt: Arguments<'_>) -> Result {
|
||||||
if let Some(s) = fmt.as_const_str() { self.buf.write_str(s) } else { write(self.buf, fmt) }
|
if let Some(s) = fmt.as_statically_known_str() {
|
||||||
|
self.buf.write_str(s)
|
||||||
|
} else {
|
||||||
|
write(self.buf, fmt)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Flags for formatting
|
/// Flags for formatting
|
||||||
@ -2308,7 +2312,7 @@ impl Write for Formatter<'_> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn write_fmt(&mut self, args: Arguments<'_>) -> Result {
|
fn write_fmt(&mut self, args: Arguments<'_>) -> Result {
|
||||||
if let Some(s) = args.as_const_str() {
|
if let Some(s) = args.as_statically_known_str() {
|
||||||
self.buf.write_str(s)
|
self.buf.write_str(s)
|
||||||
} else {
|
} else {
|
||||||
write(self.buf, args)
|
write(self.buf, args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user