Struct laby::RenderRaw

source ·
pub struct RenderRaw<S>(pub S)
where
         S: AsRef<str>;
Expand description

Wraps an AsRef<str>, rendering it without escaping.

When rendered, the value will be written to the output buffer directly without being escaped.

Consider using the raw! macro instead of constructing this type manually.

Example

Using this struct is equivalent to writing to the output buffer directly using push_str instead of escaping using escape.

struct Raw<'a>(&'a str);

impl Render for Raw<'_> {
    #[inline]
    fn render(self, buf: &mut Buffer) {
        // escape(self.0, buf);
        buf.push_str(self.0); // not escaped
    }
}

let s = render!(Raw("\""));

assert_eq!(s, "\"");
assert_ne!(s, "&quot;");

Tuple Fields§

§0: S

The value to write without escaping.

Trait Implementations§

source§

impl<S> From<S> for RenderRaw<S>where S: AsRef<str>,

source§

fn from(s: S) -> Self

Converts to this type from the input type.
source§

impl<S> Render for RenderRaw<S>where S: AsRef<str>,

source§

fn render(self, buf: &mut Buffer)

Formats this value into the given output buffer, consuming itself.

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for RenderRaw<S>where S: RefUnwindSafe,

§

impl<S> Send for RenderRaw<S>where S: Send,

§

impl<S> Sync for RenderRaw<S>where S: Sync,

§

impl<S> Unpin for RenderRaw<S>where S: Unpin,

§

impl<S> UnwindSafe for RenderRaw<S>where S: 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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<!> for T

const: unstable · source§

fn from(t: !) -> T

Converts to this type from the input type.
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.