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§

source§

impl<'a> Sliced<&'a str, Range<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<&'a str, RangeFrom<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<&'a str, RangeFull>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<&'a str, RangeInclusive<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<&'a str, RangeTo<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<&'a str, RangeToInclusive<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, Range<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, RangeFrom<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, RangeFull>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, RangeInclusive<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, RangeTo<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

source§

impl<'a> Sliced<AsciiStr<'a>, RangeToInclusive<usize>>

source

pub const fn const_debug_fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

source

pub const fn const_display_fmt( &self, f: &mut Formatter<'_> ) -> Result<(), Error>

Trait Implementations§

source§

impl<'a> FormatMarker for Sliced<&'a str, Range<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, Range<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<&'a str, RangeFrom<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, RangeFrom<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<&'a str, RangeFull>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, RangeFull>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<&'a str, RangeInclusive<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, RangeInclusive<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<&'a str, RangeTo<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, RangeTo<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<&'a str, RangeToInclusive<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<&'a str, RangeToInclusive<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, Range<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, Range<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeFrom<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, RangeFrom<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeFull>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, RangeFull>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeInclusive<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, RangeInclusive<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeTo<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, RangeTo<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types
source§

impl<'a> FormatMarker for Sliced<AsciiStr<'a>, RangeToInclusive<usize>>

§

type Kind = IsNotStdKind

What kind of type this is, this can be one of: Read more
§

type This = Sliced<AsciiStr<'a>, RangeToInclusive<usize>>

The type after dereferencing, implemented as type This = Self; for all non-reference types

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> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.