strck

Trait IntoCheck

source
pub trait IntoCheck:
    Sized
    + AsRef<str>
    + 'static {
    // Required method
    fn check<I: Invariant>(self) -> Result<Check<I, Self>, I::Error>;
}
Expand description

Conversion into a Check.

Required Methods§

source

fn check<I: Invariant>(self) -> Result<Check<I, Self>, I::Error>

Returns a validated Check owning self.

Note that Check uses the input of IntoCheck::check as its backing storage, meaning that "this".check() will return a Check<I, &'static str>. Although this is technically valid, it’s strongly recommended to use Ck for string slices instead to avoid confusion.

§Examples

Creating a Unicode ident from a formatted string:

use strck_ident::{Check, Ck, IntoCheck, unicode::UnicodeIdent};

fn wrapper_name(name: &Ck<UnicodeIdent>) -> Check<UnicodeIdent> {
    format!("lil_{name}").check().unwrap()
}

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<T: AsRef<str> + 'static> IntoCheck for T