Signed-off-by: Ava Hahn <ava@aidanis.online>
This commit is contained in:
Ava Hahn 2023-03-01 11:38:02 -08:00
parent ecbc47d4fe
commit bc09cb07b1
Signed by untrusted user who does not match committer: affine
GPG key ID: 3A4645B8CF806069
17 changed files with 236 additions and 217 deletions

View file

@ -66,7 +66,7 @@ pub struct Seg {
* How this is an acceptable solution I have
* not a single clue.
*/
_lifetime_variance_determinant: PhantomData<()>
_lifetime_variance_determinant: PhantomData<()>,
}
static NOTHING: Ctr = Ctr::None;
@ -83,7 +83,6 @@ impl Ctr {
Ctr::None => Type::None,
}
}
}
impl Seg {
@ -96,12 +95,12 @@ impl Seg {
pub fn append(&mut self, obj: Box<Ctr>) {
if let Ctr::None = &*(self.car) {
self.car = obj;
return
return;
}
if let Ctr::Seg(s) = &mut *(self.cdr) {
s.append(obj);
return
return;
}
if let Ctr::None = &mut *(self.cdr) {
@ -148,7 +147,10 @@ impl Seg {
*/
pub fn len(&self) -> u128 {
let mut len = 0;
self.circuit(&mut |_c: &Ctr| -> bool { len += 1; true });
self.circuit(&mut |_c: &Ctr| -> bool {
len += 1;
true
});
len
}
@ -167,7 +169,9 @@ impl Seg {
fn seg_to_string(s: &Seg, parens: bool) -> String {
let mut string = String::new();
if parens { string.push('('); }
if parens {
string.push('(');
}
match *(s.car) {
Ctr::None => string.push_str("<nil>"),
_ => string.push_str(&s.car.to_string()),
@ -175,10 +179,14 @@ fn seg_to_string(s: &Seg, parens: bool) -> String {
string.push(' ');
match &*(s.cdr) {
Ctr::Seg(inner) => string.push_str(&seg_to_string(inner, false)),
Ctr::None => {string.pop();},
Ctr::None => {
string.pop();
}
_ => string.push_str(&s.cdr.to_string()),
}
if parens { string.push(')'); }
if parens {
string.push(')');
}
string
}
@ -202,7 +210,7 @@ impl Index<usize> for Seg {
}
if let Ctr::Seg(ref s) = *self.cdr {
return s.index(idx - 1)
return s.index(idx - 1);
}
&NOTHING
@ -236,7 +244,7 @@ impl fmt::Display for Ctr {
} else {
write!(f, "F")
}
},
}
Ctr::Seg(s) => write!(f, "{}", s),
Ctr::None => Ok(()),
}