Skip to main content

Output

Struct Output 

Source
pub struct Output<const CAPACITY: usize> {
    pub bytes: [u8; CAPACITY],
    pub length: usize,
}
Expand description

Const-evaluable output buffer.

With CAPACITY == 0 nothing is stored and only Output::length advances (the measuring pass). With CAPACITY > 0 the bytes are written into bytes, which must be exactly the length the measuring pass reported; anything else is an out-of-bounds const-eval error.

Fields§

§bytes: [u8; CAPACITY]

The rendered bytes. Meaningful only when CAPACITY is the measured length.

§length: usize

The number of bytes rendered.

Implementations§

Source§

impl<const CAPACITY: usize> Output<CAPACITY>

Source

pub const fn new() -> Self

A fresh, empty writer.

Source

pub const fn put(&mut self, text: &str)

Append a string.

Source

pub const fn put_usize(&mut self, value: usize)

Append a decimal integer.

Source

pub const fn put_quoted(&mut self, text: &str)

Append a string as a double-quoted Javascript literal, escaping backslashes and quotes.

Source

pub const fn put_ident(&mut self, name: &str)

Append an identifier, adding a trailing underscore if it is a reserved word.

Source

pub const fn put_quoted_ident(&mut self, name: &str)

Append an identifier as a quoted string, with the same underscore rule.

Source

pub const fn indent(&mut self, count: usize)

Append count levels of two-space indentation.

Trait Implementations§

Source§

impl<const CAPACITY: usize> Default for Output<CAPACITY>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<const CAPACITY: usize> Freeze for Output<CAPACITY>
where [u8; CAPACITY]: Freeze,

§

impl<const CAPACITY: usize> RefUnwindSafe for Output<CAPACITY>

§

impl<const CAPACITY: usize> Send for Output<CAPACITY>
where [u8; CAPACITY]: Send,

§

impl<const CAPACITY: usize> Sync for Output<CAPACITY>
where [u8; CAPACITY]: Sync,

§

impl<const CAPACITY: usize> Unpin for Output<CAPACITY>
where [u8; CAPACITY]: Unpin,

§

impl<const CAPACITY: usize> UnsafeUnpin for Output<CAPACITY>

§

impl<const CAPACITY: usize> UnwindSafe for Output<CAPACITY>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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 T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.