Struct OperatorSet

Source
pub struct OperatorSet { /* private fields */ }
Expand description

OperatorSet struct used to specify non-default operator symbols for custom_parse function

§Examples

§Using the common sets

use rustlogic::operators;

let mathematical_version = operators::common_sets::mathematical();

// We create a parsed logic node
let parse_result = rustlogic::custom_parse("(![A]*[B])+[C]", &mathematical_version);

// -- snipp

For all the common sets click here

§Defining your own sets

use rustlogic::operators::OperatorSet;

// Create a operator set with words
let worded_version = OperatorSet::new(
    " AND ", " OR ", "NOT ", "TRUE", "FALSE", "(", ")", "$[", "]",
);

// Attempt to parse a logical string
let parse_result = rustlogic::custom_parse("(NOT $[A] AND $[B]) OR $[C]", &worded_version);

// -- snipp

§Adjusting a pre-existing set

use rustlogic::operators;

// Adjust the group brackets to be curly
let curly_bracket_groups = operators::common_sets::default()
     .adjust_group_open("{")
     .adjust_group_close("}");

// We create a parsed logic node
let parse_result = rustlogic::custom_parse("{~[A]&[B]}|[C]", &curly_bracket_groups);

// -- snipp

Implementations§

Source§

impl OperatorSet

Source

pub fn new( and: &str, or: &str, not: &str, true_symbol: &str, false_symbol: &str, group_open: &str, group_close: &str, variable_open: &str, variable_close: &str, ) -> OperatorSet

Source

pub fn adjust_and(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn and(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_or(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn or(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_not(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn not(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_true_symbol(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn true_symbol(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_false_symbol(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn false_symbol(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_group_open(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn group_open(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_group_close(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn group_close(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_variable_open(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn variable_open(&self) -> &str

Getter used to fetch operator within OperatorSet

Source

pub fn adjust_variable_close(self, to: &str) -> OperatorSet

Setter used to adjust operator within OperatorSet

Source

pub fn variable_close(&self) -> &str

Getter used to fetch operator within OperatorSet

Trait Implementations§

Source§

impl Clone for OperatorSet

Source§

fn clone(&self) -> OperatorSet

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§

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.