Struct const_format::Sliced
source · pub struct Sliced<T, R>(pub T, pub R);
Available on crate feature
fmt
only.Expand description
Wrapper for writing a range of a string slice.
This is a workaround for not being able to do &string[start..end]
at compile-time.
Example
#![feature(const_mut_refs)]
use const_format::Sliced;
use const_format::{concatc, formatc};
const NUMS: &str = "0123456789";
const SRC: &str = "foo bar baz";
assert_eq!(concatc!(Sliced(NUMS, 1..=4)), "1234");
assert_eq!(concatc!(Sliced(SRC, 0..5), "ros."), "foo bros.");
assert_eq!(formatc!("{}", Sliced(NUMS, 4..)), "456789");
assert_eq!(formatc!("{}t", Sliced(SRC, 4..7)), "bart");
Tuple Fields§
§0: T
§1: R
Implementations§
Trait Implementations§
source§impl<'a> FormatMarker for Sliced<&'a str, RangeInclusive<usize>>
impl<'a> FormatMarker for Sliced<&'a str, RangeInclusive<usize>>
§type Kind = IsNotStdKind
type Kind = IsNotStdKind
What kind of type this is, this can be one of: Read more
source§impl<'a> FormatMarker for Sliced<&'a str, RangeToInclusive<usize>>
impl<'a> FormatMarker for Sliced<&'a str, RangeToInclusive<usize>>
§type Kind = IsNotStdKind
type Kind = IsNotStdKind
What kind of type this is, this can be one of: Read more
source§impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeInclusive<usize>>
impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeInclusive<usize>>
§type Kind = IsNotStdKind
type Kind = IsNotStdKind
What kind of type this is, this can be one of: Read more
source§impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeToInclusive<usize>>
impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeToInclusive<usize>>
§type Kind = IsNotStdKind
type Kind = IsNotStdKind
What kind of type this is, this can be one of: Read more
Auto Trait Implementations§
impl<T, R> RefUnwindSafe for Sliced<T, R>where R: RefUnwindSafe, T: RefUnwindSafe,
impl<T, R> Send for Sliced<T, R>where R: Send, T: Send,
impl<T, R> Sync for Sliced<T, R>where R: Sync, T: Sync,
impl<T, R> Unpin for Sliced<T, R>where R: Unpin, T: Unpin,
impl<T, R> UnwindSafe for Sliced<T, R>where R: UnwindSafe, T: UnwindSafe,
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