* Arithmetic support:
* `is/2` works for `(+)/2`, `(-)/{1,2}`, `(*)/2`, `(//)/2`, `(^)/2`, `(div)/2`, `(/)/2`, `(rdiv)/2`,
- `(xor)/2`, `(rem)/2`, `(mod)/2`, `(/\)/2`, `(\/)/2`, `(>>)/2`, `(<<)/2`.
+ `(xor)/2`, `(rem)/2`, `(mod)/2`, `(/\)/2`, `(\/)/2`, `(>>)/2`, `(<<)/2`, `abs/1`.
* Comparison operators: `>`, `<`, `=<`, `>=`, `=:=`, `=\=`.
* `(:)/2`
* `(@>)/2`
use prolog::tabled_rc::*;
-use std::cell::{Ref, RefCell};
+use std::cell::{Cell, Ref, RefCell};
use std::cmp::Ordering;
use std::hash::{Hash, Hasher};
+use std::rc::Rc;
#[derive(PartialOrd, PartialEq, Ord, Eq)]
pub struct StringListWrapper(RefCell<String>);
body: TabledRc<StringListWrapper>,
cursor: usize, // use this to generate a chars() iterator on the fly,
// and skip over the first cursor chars.
- expandable: bool
+ expandable: Rc<Cell<bool>>
}
impl Hash for StringList {
fn hash<H: Hasher>(&self, state: &mut H) {
- let h = self.borrow().hash(state);
- (h, self.cursor, self.expandable).hash(state);
+ (self.borrow().as_str(), self.cursor, self.expandable.get()).hash(state);
}
}
impl PartialOrd for StringList {
- fn partial_cmp(&self, other: &Self) -> Option<Ordering>
- {
+ fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.body.cmp(&other.body))
}
}
impl Ord for StringList {
- fn cmp(&self, other: &Self) -> Ordering
- {
+ fn cmp(&self, other: &Self) -> Ordering {
self.body.cmp(&other.body)
}
}
impl PartialEq for StringList {
- fn eq(&self, other: &Self) -> bool
- {
+ fn eq(&self, other: &Self) -> bool {
self.body == other.body && self.cursor == other.cursor && self.expandable == other.expandable
}
}
StringList {
cursor: 0,
body,
- expandable
+ expandable: Rc::new(Cell::new(expandable))
}
}