//! Checked strings containing Unicode identifiers according to the //! [Unicode Standard Annex #31](https://www.unicode.org/reports/tr31/). //! //! # Examples //! //! ```rust //! use strck_ident::{IntoCk, unicode::UnicodeIdent}; //! //! assert!("foo".ck::<UnicodeIdent>().is_ok()); //! assert!("struct".ck::<UnicodeIdent>().is_ok()); //! assert!("Москва".ck::<UnicodeIdent>().is_ok()); //! assert!("東京".ck::<UnicodeIdent>().is_ok()); //! //! assert!("_identifier".ck::<UnicodeIdent>().is_err()); //! assert!("r#try".ck::<UnicodeIdent>().is_err()); //! assert!("".ck::<UnicodeIdent>().is_err()); //! ``` //! //! # Aliases //! //! This module exposes [`Ident`] and [`IdentBuf`], which alias `Ck<UnicodeIdent>` //! and `Check<UnicodeIdent>` respectively. These aliases are preferred to keep //! type signatures succinct. //! //! These are also exported under the root, and can be accessed as //! `strck_ident::Ident` and `strck_ident::IdentBuf`. use core::fmt; use strck::{Check, Ck, Invariant};
/// An [`Invariant`] for unicode identifiers according to /// [Unicode Standard Annex #31](https://www.unicode.org/reports/tr31/). /// /// # Invariants /// /// * The string is nonempty. /// * The first character is XID_Start. /// * Any following characters are XID_Continue. #[derive(Clone, Debug)] pubstruct UnicodeIdent;
/// Borrowed checked string containing a Unicode identifier. /// /// See [`UnicodeIdent`] for more details. pubtype Ident = Ck<UnicodeIdent>;
/// Owned checked string containing a Unicode identifier. /// /// See [`UnicodeIdent`] for more details. pubtype IdentBuf<B = String> = Check<UnicodeIdent, B>;
/// The error type returned from checking invariants of [`UnicodeIdent`]. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pubenum Error { /// Empty string.
Empty,
/// The first character isn't XID_Start.
Start(char),
/// A trailing character isn't XID_Continue. Continue(char),
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.