Skip to main content

FieldName

Struct FieldName 

#[repr(transparent)]
pub struct FieldName(str);
Expand description

Name of a field or of an enum variant, such as thing_name.

It starts with a letter and continues with letters and digits. One _ may separate them.

Tuple Fields§

§0: str

Implementations§

§

impl FieldName

pub const fn as_str(&self) -> &str

Returns the name as a string.

pub const fn from_static(name: &'static str) -> &'static Self

Checks a static name against the rules for field names.

This is meant for const contexts, where an invalid name fails the build:

use varlet_idl::FieldName;

const NAME: &FieldName = FieldName::from_static("thing_name");
assert_eq!(NAME.as_str(), "thing_name");

Use new for names that come from input.

§Panics

Panics if the name breaks the rules.

pub const fn new(name: &str) -> Result<&Self, InvalidName>

Checks name against the rules for field names.

§Errors

Returns the position of the first byte that breaks the rules.

pub(crate) const fn equals(&self, other: &Self) -> bool

const fn check(rest: &[u8]) -> Result<(), InvalidName>

Checks the bytes of a name against the rules.

const fn cast(name: &str) -> &Self

Trait Implementations§

§

impl Debug for FieldName

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Display for FieldName

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
§

impl Eq for FieldName

§

impl Hash for FieldName

§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
§

impl Ord for FieldName

§

fn cmp(&self, other: &FieldName) -> Ordering

This method returns an Ordering between self and other. Read more
§

impl PartialEq for FieldName

§

fn eq(&self, other: &FieldName) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
§

impl PartialOrd for FieldName

§

fn partial_cmp(&self, other: &FieldName) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl StructuralPartialEq for FieldName

Auto Trait Implementations§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more