pub struct RefMessage<'a, const N: usize> { /* private fields */ }Implementations§
Source§impl<'a, const N: usize> RefMessage<'a, N>
impl<'a, const N: usize> RefMessage<'a, N>
Sourcepub const unsafe fn new_unchecked(formats: &'a [RefMessageFormat<'a>]) -> Self
pub const unsafe fn new_unchecked(formats: &'a [RefMessageFormat<'a>]) -> Self
§Safety
The caller must ensure that the formats slice is valid.
pub const fn new( formats: &'a [RefMessageFormat<'a>], ) -> Result<Self, CreateMessageError>
pub const fn new_panic(formats: &'a [RefMessageFormat<'a>]) -> Self
pub fn format(&self, args: &[&str; N]) -> String
pub const fn len(&self) -> usize
pub const fn is_empty(&self) -> bool
pub const fn formats(&self) -> &'a [RefMessageFormat<'a>]
Source§impl<const N: usize> RefMessage<'static, N>
impl<const N: usize> RefMessage<'static, N>
Sourcepub const unsafe fn const_format<const SIZE: usize>(
&self,
args: &[&[u8]; N],
) -> UtilBufWrapper<SIZE>
pub const unsafe fn const_format<const SIZE: usize>( &self, args: &[&[u8]; N], ) -> UtilBufWrapper<SIZE>
Formats the message with the given arguments.
§Safety
Ensure that the total of all characters does not exceed SIZE
§Example
use local_fmt::{RefMessageFormat, StaticMessage, utils::UtilBufWrapper};
const MESSAGE: StaticMessage<2> = StaticMessage::new_panic(&[
RefMessageFormat::RefText("Hello! "),
RefMessageFormat::Placeholder(0),
RefMessageFormat::RefText(" World! "),
RefMessageFormat::Placeholder(1),
RefMessageFormat::RefText("!"),
]);
const TEXT: &str = {
const BUF: UtilBufWrapper<32> = unsafe {
MESSAGE.const_format::<32>(&[b"Beautiful", b"Rust!"])
};
BUF.as_str()
};
assert_eq!(TEXT, "Hello! Beautiful World! Rust!!");Trait Implementations§
Source§impl<const N: usize> CheckStaticMessageArg<RefMessage<'static, N>> for &'static str
impl<const N: usize> CheckStaticMessageArg<RefMessage<'static, N>> for &'static str
const IS_INVALID: Option<StaticMessage<2>>
Source§impl<const N: usize, const M: usize> CheckStaticMessageArg<RefMessage<'static, N>> for StaticMessage<M>
impl<const N: usize, const M: usize> CheckStaticMessageArg<RefMessage<'static, N>> for StaticMessage<M>
const IS_INVALID: Option<StaticMessage<2>>
Source§impl<'a, const N: usize> Clone for RefMessage<'a, N>
impl<'a, const N: usize> Clone for RefMessage<'a, N>
Source§fn clone(&self) -> RefMessage<'a, N>
fn clone(&self) -> RefMessage<'a, N>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<'a, const N: usize> Debug for RefMessage<'a, N>
impl<'a, const N: usize> Debug for RefMessage<'a, N>
Source§impl<const N: usize> Display for RefMessage<'_, N>
impl<const N: usize> Display for RefMessage<'_, N>
Source§impl<'a, const N: usize> Hash for RefMessage<'a, N>
impl<'a, const N: usize> Hash for RefMessage<'a, N>
Source§impl<'a, const N: usize> Ord for RefMessage<'a, N>
impl<'a, const N: usize> Ord for RefMessage<'a, N>
Source§fn cmp(&self, other: &RefMessage<'a, N>) -> Ordering
fn cmp(&self, other: &RefMessage<'a, N>) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<'a, const N: usize> PartialEq for RefMessage<'a, N>
impl<'a, const N: usize> PartialEq for RefMessage<'a, N>
Source§impl<'a, const N: usize> PartialOrd for RefMessage<'a, N>
impl<'a, const N: usize> PartialOrd for RefMessage<'a, N>
Source§impl<const N: usize> Serialize for RefMessage<'_, N>
impl<const N: usize> Serialize for RefMessage<'_, N>
impl<'a, const N: usize> Eq for RefMessage<'a, N>
impl<'a, const N: usize> StructuralPartialEq for RefMessage<'a, N>
Auto Trait Implementations§
impl<'a, const N: usize> Freeze for RefMessage<'a, N>
impl<'a, const N: usize> RefUnwindSafe for RefMessage<'a, N>
impl<'a, const N: usize> Send for RefMessage<'a, N>
impl<'a, const N: usize> Sync for RefMessage<'a, N>
impl<'a, const N: usize> Unpin for RefMessage<'a, N>
impl<'a, const N: usize> UnwindSafe for RefMessage<'a, N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more