//! Checked strings containing Rust identifiers. //! //! Raw identifiers are unsupported. //! //! # Examples //! //! ```rust //! use strck_ident::{IntoCk, rust::RustIdent}; //! //! assert!("foo".ck::<RustIdent>().is_ok()); //! assert!("_identifier".ck::<RustIdent>().is_ok()); //! assert!("Москва".ck::<RustIdent>().is_ok()); //! assert!("東京".ck::<RustIdent>().is_ok()); //! //! assert!("struct".ck::<RustIdent>().is_err()); //! assert!("r#try".ck::<RustIdent>().is_err()); //! assert!("".ck::<RustIdent>().is_err()); //! ``` //! //! # Aliases //! //! This module exposes [`Ident`] and [`IdentBuf`], which alias `Ck<RustIdent>` //! and `Check<RustIdent>` respectively. These aliases are preferred to keep //! type signatures succinct. //! //! # Requirements //! //! This module is only available when the `rust` feature flag is enabled. usecrate::unicode; use core::fmt; use strck::{Check, Ck, Invariant};
/// An [`Invariant`] for Rust identifiers. /// /// Raw identifiers are unsupported. /// /// # Invariants /// /// * The string is nonempty. /// * The first character is `_` or XID_Start. /// * Any following characters are XID_Continue. /// * The string isn't a single underscore, e.g. `"_"`. /// * The string isn't a [strict] or [reserved] keyword. /// /// [strict]: https://doc.rust-lang.org/reference/keywords.html#strict-keywords /// [reserved]: https://doc.rust-lang.org/reference/keywords.html#reserved-keywords #[derive(Clone, Debug)] pubstruct RustIdent;
/// Borrowed checked string containing a Rust identifier. /// /// See [`RustIdent`] for more details. pubtype Ident = Ck<RustIdent>;
/// Owned checked string containing a Rust identifier. /// /// See [`RustIdent`] for more details. pubtype IdentBuf<B = String> = Check<RustIdent, B>;
/// The error type returned from checking the invariants of [`RustIdent`]. #[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord)] pubenum Error { /// An invalid unicode identifier.
Unicode(unicode::Error),
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.