pub struct VarSubstitution { /* private fields */ }Expand description
用于表示「变量替换」的字典
- 🎯NAL-6中的「变量替换」「变量代入」
Implementations§
Source§impl VarSubstitution
impl VarSubstitution
Sourcepub fn from_pairs(pairs: impl IntoIterator<Item = (Term, Term)>) -> Self
pub fn from_pairs(pairs: impl IntoIterator<Item = (Term, Term)>) -> Self
从其它构造出「散列映射」的地方构造
Sourcepub fn chain_get(&self, key: &Term) -> Option<&Term>
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
Sourcepub fn put(&mut self, key: &Term, value: Term)
pub fn put(&mut self, key: &Term, value: Term)
设置「替代项」
- 🎯寻找可替换变量,并返回结果
- 🚩只在没有键时复制
key,并且总是覆盖value值
Sourcepub fn reduce_identities(&mut self)
pub fn reduce_identities(&mut self)
删除映射中的「恒等替换」
- 📄
$1 => $1
Source§impl VarSubstitution
🆕将上述方法放在映射表的方法上
impl VarSubstitution
🆕将上述方法放在映射表的方法上
Sourcepub fn apply_to(&self, to: CompoundTermRefMut<'_>)
pub fn apply_to(&self, to: CompoundTermRefMut<'_>)
将映射表的替换模式应用到「复合词项可变引用」上
- 🎯用于「只需单个替换」的情况
- 📄首先出自「条件演绎/归纳」
Sourcepub fn apply_to_term(&self, to: &mut Term)
pub fn apply_to_term(&self, to: &mut Term)
尝试将映射表的替换模式应用到任意词项上
- 🎯用于「先应用,再判断词项类型」的情况
Trait Implementations§
Source§impl Clone for VarSubstitution
impl Clone for VarSubstitution
Source§fn clone(&self) -> VarSubstitution
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VarSubstitution
impl Debug for VarSubstitution
Source§impl Default for VarSubstitution
impl Default for VarSubstitution
Source§fn default() -> VarSubstitution
fn default() -> VarSubstitution
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for VarSubstitution
impl RefUnwindSafe for VarSubstitution
impl Send for VarSubstitution
impl Sync for VarSubstitution
impl Unpin for VarSubstitution
impl UnsafeUnpin for VarSubstitution
impl UnwindSafe for VarSubstitution
Blanket Implementations§
Source§impl<T> BoostWithOption for T
impl<T> BoostWithOption for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more
Source§impl<T> JoinTo for T
impl<T> JoinTo for T
Source§fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
fn join_to<S>(self, out: &mut String, sep: impl AsRef<str>)
将字串集中拼接到一个「目标字串」中,中途不创建任何辅助字符串 Read more