Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -743,23 +743,6 @@ impl<'a> Arguments<'a> {
}
}

impl<'a> Arguments<'a> {
/// Create a `fmt::Arguments` object for a single static string.
///
/// Formatting this `fmt::Arguments` will just produce the string as-is.
#[inline]
#[unstable(feature = "fmt_arguments_from_str", issue = "148905")]
pub const fn from_str(s: &'static str) -> Arguments<'a> {
// SAFETY: This is the "static str" representation of fmt::Arguments; see above.
unsafe {
Arguments {
template: mem::transmute(s.as_ptr()),
args: mem::transmute(s.len() << 1 | 1),
}
}
}
}

#[doc(hidden)]
#[unstable(feature = "fmt_internals", issue = "none")]
impl<'a> Arguments<'a> {
Expand Down Expand Up @@ -824,6 +807,21 @@ impl<'a> Arguments<'a> {
}

impl<'a> Arguments<'a> {
/// Create a `fmt::Arguments` object for a single static string.
///
/// Formatting this `fmt::Arguments` will just produce the string as-is.
#[inline]
#[unstable(feature = "fmt_arguments_from_str", issue = "148905")]
pub const fn from_str(s: &'static str) -> Arguments<'a> {
// SAFETY: This is the "static str" representation of fmt::Arguments; see above.
unsafe {
Arguments {
template: mem::transmute(s.as_ptr()),
args: mem::transmute(s.len() << 1 | 1),
}
}
}

/// Gets the formatted string, if it has no arguments to be formatted at runtime.
///
/// This can be used to avoid allocations in some cases.
Expand Down
Loading