pub struct Sliced<T, R>(pub T, pub R);
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
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>>
Source§impl<'a> FormatMarker for Sliced<&'a str, RangeToInclusive<usize>>
impl<'a> FormatMarker for Sliced<&'a str, RangeToInclusive<usize>>
Source§impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeInclusive<usize>>
impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeInclusive<usize>>
Source§impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeToInclusive<usize>>
impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeToInclusive<usize>>
Auto Trait Implementations§
impl<T, R> Freeze for Sliced<T, R>
impl<T, R> RefUnwindSafe for Sliced<T, R>where
T: RefUnwindSafe,
R: RefUnwindSafe,
impl<T, R> Send for Sliced<T, R>
impl<T, R> Sync for Sliced<T, R>
impl<T, R> Unpin for Sliced<T, R>
impl<T, R> UnwindSafe for Sliced<T, R>where
T: UnwindSafe,
R: 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
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.