Struct Symbol

Source
pub struct Symbol(/* private fields */);
Expand description

Represents a symbol.

This includes numbers, strings, functions (including constants when arguments are empty and tuples when the name is empty), #inf and #sup.

Implementations§

Source§

impl Symbol

Source

pub fn create_number(number: i32) -> Symbol

Construct a symbol representing a number.

Source

pub fn create_supremum() -> Symbol

Construct a symbol representing #sup.

Source

pub fn create_infimum() -> Symbol

Construct a symbol representing #inf

Source

pub fn create_string(string: &str) -> Result<Symbol, ClingoError>

Construct a symbol representing a string.

§Arguments
  • string - the string
§Errors:
Source

pub fn create_id(name: &str, positive: bool) -> Result<Symbol, ClingoError>

Construct a symbol representing an id.

Note: This is just a shortcut for Symbol::create_function() with empty arguments.

§Arguments
  • name - the name of the symbol
  • positive - whether the symbol has a classical negation sign
§Errors
Source

pub fn create_function( name: &str, arguments: &[Symbol], positive: bool, ) -> Result<Symbol, ClingoError>

Construct a symbol representing a function or tuple.

Note: To create tuples, the empty string has to be used as name.

§Arguments
  • name - the name of the function
  • arguments - the arguments of the function
  • positive - whether the symbol has a classical negation sign
§Errors
Source

pub fn number(self) -> Result<i32, ClingoError>

Get the number of a symbol.

§Errors
Source

pub fn name(&self) -> Result<&'static str, ClingoError>

Get the name of a symbol.

Note: The string is internalized and valid for the duration of the process.

§Errors
Source

pub fn string(&self) -> Result<&'static str, ClingoError>

Get the string of a symbol.

Note: The string is internalized and valid for the duration of the process.

§Errors
Source

pub fn is_positive(self) -> Result<bool, ClingoError>

Check if a function is positive (does not have a sign).

§Errors
Source

pub fn is_negative(self) -> Result<bool, ClingoError>

Check if a function is negative (has a sign).

§Errors
Source

pub fn arguments(self) -> Result<Vec<Symbol>, ClingoError>

Get the arguments of a symbol.

§Errors
Source

pub fn symbol_type(self) -> Result<SymbolType, ClingoError>

Get the type of a symbol.

§Errors

Trait Implementations§

Source§

impl Clone for Symbol

Source§

fn clone(&self) -> Symbol

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 Debug for Symbol

Source§

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

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

impl Display for Symbol

Source§

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

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

impl From<Symbol> for clingo_symbol_t

Source§

fn from(symbol: Symbol) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Symbol

Source§

fn from(symbol: clingo_symbol_t) -> Self

Converts to this type from the input type.
Source§

impl FromSymbol for Symbol

Source§

impl Hash for Symbol

Source§

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

Calculate a hash code of a symbol.

1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Symbol

Source§

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

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

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

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

impl PartialOrd for Symbol

Source§

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

Compare two symbols.

Symbols are first compared by type. If the types are equal, the values are compared (where strings are compared using strcmp). Functions are first compared by signature and then lexicographically by arguments.

1.0.0 · 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 · 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 · 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 · 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
Source§

impl ToSymbol for Symbol

Source§

impl Copy for Symbol

Source§

impl Eq for Symbol

Auto Trait Implementations§

§

impl Freeze for Symbol

§

impl RefUnwindSafe for Symbol

§

impl Send for Symbol

§

impl Sync for Symbol

§

impl Unpin for Symbol

§

impl UnwindSafe for Symbol

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.