Struct Alphabet

Source
pub struct Alphabet<T: Copy + Hash + Eq> { /* private fields */ }
Expand description

Represents a set of characters that are valid in a crate::BlockId.

An alphabet is generic over the type of data used to represent a “character”, but Alphabet<char> is used when generating string codes (otherwise, BlockId will generate a Vec<T>).

Several built-in alphabets are provided.

Examples:

let alpha1: Alphabet<char> = Alphabet::alphanumeric();
let hexchars: Vec<char> = "0123456789abcdef".chars().collect();
let alpha2: Alphabet<char> = Alphabet::new(&hexchars);
let alpha3: Alphabet<u32> = Alphabet::new(&[1234, 5678, 2345]);

Implementations§

Source§

impl<T: Copy + Hash + Eq> Alphabet<T>

Source

pub fn new(alphabet: &[T]) -> Self

Construct an alphabet from a list of values.

Panics if the alphabet contains duplicates, or contains more than 256 elements.

Source

pub fn len(&self) -> u8

Source§

impl Alphabet<char>

Source

pub fn alphanumeric() -> Alphabet<char>

Returns an alphabet with lower- and upper-case letters, and numeral digits.

Source

pub fn lowercase_alphanumeric() -> Alphabet<char>

Returns an alphabet with lower-case letters and numeral digits.

Source

pub fn lowercase_alpha() -> Alphabet<char>

Returns an alphabet with lowercase letters only.

Trait Implementations§

Source§

impl<T: Clone + Copy + Hash + Eq> Clone for Alphabet<T>

Source§

fn clone(&self) -> Alphabet<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Alphabet<T>

§

impl<T> RefUnwindSafe for Alphabet<T>
where T: RefUnwindSafe,

§

impl<T> Send for Alphabet<T>
where T: Send,

§

impl<T> Sync for Alphabet<T>
where T: Sync,

§

impl<T> Unpin for Alphabet<T>
where T: Unpin,

§

impl<T> UnwindSafe for Alphabet<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V