Dictionary

Struct Dictionary 

Source
pub struct Dictionary<D> { /* private fields */ }
Expand description

a list of Datapairs

Implementations§

Source§

impl<D> Dictionary<D>

Source

pub fn new() -> Self

create a new Dictionary for D

§Return
Dictionary<D>
§Examples
let dictonary:Dictionary<String> = Dictionary::new();
§Coution

The type for the data has to be set. Wrong example:

let dictionary = Dictionary::new();

This gives an error, because the type for the data is not clear.

Source

pub fn add(&mut self, k: String, d: D)

add data to the Dictionary

§Params
p: Datapair<D>
§Example
dictionary.add(String::from("Lola"),String::from("Sky"));
Source

pub fn add_pair(&mut self, p: Datapair<D>)

add a pair to the Dictionary

§Params
k: String // the key
d: D // the data
§Example
let pair: Datapair<String> = Datapair::new(String::from("Marie"),String::from("Karate"))
dictionary.add_pair(pair);   
Source

pub fn remove(&mut self, k: String)

removes a pair from the Dictionary

§Params
k: String // the key
§Example
dictionary.remove(String::from("Lola"));
Source

pub fn change_data(&mut self, k: String, d: D)

changes the data for the given key

§Params
k:String // the key
d:D // the new data
§Example
dictionary.change_data(String::from("Maxime"),String::from("Swimming"));
Source

pub fn change_key(&mut self, ok: String, nk: String)

changes the key for the given old key

§Params
ok:String // the old key
nk:String // the new key
§Example
dictionary.change_key(String::from("Anna"),String::from("Anna-Lena"));
Source

pub fn get_pair(&self, k: String) -> &Datapair<D>

get a specific Datapair for the given key

§Params
k:String // the key
§Return
&Dictonary<D>
§Example
let pair:Datapair<String> = dictionary.get_pair(String::from("Anna"));
Source

pub fn get_data(&self, k: String) -> &D

get the data for the given key

§Params
k:String // the key
§Return
&D
§Example
let hobby = dictionary.get_data(String::from("Anna"));
Source

pub fn clear(&mut self)

clears the Dictionary

§Example
dictionary.clear();
Source

pub fn size(&self) -> usize

gives you how many pairs are in the Dictionary

§Returns
usize
§Example
let size:usize = dictionary.size();

Trait Implementations§

Source§

impl<D: Clone> Clone for Dictionary<D>

Source§

fn clone(&self) -> Self

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

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

Performs copy-assignment from source. Read more
Source§

impl<D: Display + Clone> Display for Dictionary<D>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<D: PartialEq> PartialEq for Dictionary<D>

Source§

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

Tests for self and other values to be equal, and is used by ==.
Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

§

impl<D> Freeze for Dictionary<D>

§

impl<D> RefUnwindSafe for Dictionary<D>
where D: RefUnwindSafe,

§

impl<D> Send for Dictionary<D>
where D: Send,

§

impl<D> Sync for Dictionary<D>
where D: Sync,

§

impl<D> Unpin for Dictionary<D>
where D: Unpin,

§

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

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.