Skip to main content

VarSubstitution

Struct VarSubstitution 

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

用于表示「变量替换」的字典

  • 🎯NAL-6中的「变量替换」「变量代入」

Implementations§

Source§

impl VarSubstitution

Source

pub fn new() -> Self

构造函数

Source

pub fn from(map: impl Into<HashMap<Term, Term>>) -> Self

从其它构造出「散列映射」的地方构造

Source

pub fn from_pairs(pairs: impl IntoIterator<Item = (Term, Term)>) -> Self

从其它构造出「散列映射」的地方构造

Source

pub fn get(&self, key: &Term) -> Option<&Term>

尝试获取「替代项」

  • 🎯变量替换
Source

pub fn chain_get(&self, key: &Term) -> Option<&Term>

链式获取「变量替换」最终点

  • 🚩一路查找到头
  • 📄{A -> B, B -> C}, A => Some(C)
  • 📄{A -> B, B -> C}, B => Some(C)
  • 📄{A -> B, B -> C}, C => None
Source

pub fn has(&self, key: &Term) -> bool

尝试判断「是否有键」

  • 🎯变量重命名
Source

pub fn len(&self) -> usize

获取「可替换的变量个数」

  • 🚩映射的大小
  • 🎯变量重命名
Source

pub fn is_empty(&self) -> bool

判断「是否为空」

  • 🎯变量替换后检查「是否已替换」
Source

pub fn put(&mut self, key: &Term, value: Term)

设置「替代项」

  • 🎯寻找可替换变量,并返回结果
  • 🚩只在没有键时复制key,并且总是覆盖value
Source

pub fn reduce_identities(&mut self)

删除映射中的「恒等替换」

  • 📄$1 => $1
Source§

impl VarSubstitution

🆕将上述方法放在映射表的方法上

Source

pub fn apply_to(&self, to: CompoundTermRefMut<'_>)

将映射表的替换模式应用到「复合词项可变引用」上

  • 🎯用于「只需单个替换」的情况
    • 📄首先出自「条件演绎/归纳」
Source

pub fn apply_to_term(&self, to: &mut Term)

尝试将映射表的替换模式应用到任意词项上

  • 🎯用于「先应用,再判断词项类型」的情况

Trait Implementations§

Source§

impl Clone for VarSubstitution

Source§

fn clone(&self) -> VarSubstitution

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for VarSubstitution

Source§

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

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

impl Default for VarSubstitution

Source§

fn default() -> VarSubstitution

Returns the “default value” for a type. 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> BoostWithOption for T

Source§

fn option<C>(self, criterion: C) -> Option<Self>
where C: FnOnce(&Self) -> bool,

根据某条件把自身变为可选值 Read more
Source§

fn some(self) -> Option<Self>

将自身封装为Some Read more
Source§

fn none(self) -> Option<Self>

将自身封装为None 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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> JoinTo for T

Source§

fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§

fn join_to_new<S>(self, sep: impl AsRef<str>) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中 Read more
Source§

fn join_to_multi<S>(self, out: &mut String, sep: &[impl AsRef<str>])
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,使用多个分隔符,中途不创建任何辅助字符串 Read more
Source§

fn join_to_multi_new<S>(self, sep: &[impl AsRef<str>]) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中,使用多个分隔符 Read more
Source§

impl<T> JoinTo for T

Source§

fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§

fn join_to_new<S>(self, sep: impl AsRef<str>) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中 Read more
Source§

fn join_to_multi<S>(self, out: &mut String, sep: &[impl AsRef<str>])
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个「目标字串」中,使用多个分隔符,中途不创建任何辅助字符串 Read more
Source§

fn join_to_multi_new<S>(self, sep: &[impl AsRef<str>]) -> String
where Self: Sized + Iterator<Item = S>, S: AsRef<str>,

将字串集中拼接到一个新字串中,使用多个分隔符 Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToDebug for T
where T: Debug,

Source§

fn to_debug(&self) -> String

将对象转换为「用Debug格式化的字符串」

Source§

impl<T> ToDebug for T
where T: Debug,

Source§

fn to_debug(&self) -> String

将对象转换为「用Debug格式化的字符串」

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 = !

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

fn try_from(value: U) -> Result<T, !>

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

Source§

impl<T> Void for T

Source§

fn void(self)

Source§

impl<T> Void for T

Source§

fn void(self)