forked from AbleScript/ablescript
cycle detecion on cart print - no longer stack overflow
This commit is contained in:
parent
6d37825671
commit
3d546bb31c
|
@ -148,13 +148,12 @@ impl Display for Value {
|
||||||
cart_vec.sort_by(|x, y| x.0.partial_cmp(y.0).unwrap_or(std::cmp::Ordering::Less));
|
cart_vec.sort_by(|x, y| x.0.partial_cmp(y.0).unwrap_or(std::cmp::Ordering::Less));
|
||||||
|
|
||||||
for (idx, (key, value)) in cart_vec.into_iter().enumerate() {
|
for (idx, (key, value)) in cart_vec.into_iter().enumerate() {
|
||||||
write!(
|
write!(f, "{}", if idx != 0 { ", " } else { "" },)?;
|
||||||
f,
|
match &*value.borrow() {
|
||||||
"{}{} <= {}",
|
x if std::ptr::eq(x, self) => write!(f, "<cycle>"),
|
||||||
if idx != 0 { ", " } else { "" },
|
x => write!(f, "{x}"),
|
||||||
value.borrow(),
|
}?;
|
||||||
key
|
write!(f, " <= {key}")?;
|
||||||
)?;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write!(f, "]")
|
write!(f, "]")
|
||||||
|
|
Loading…
Reference in a new issue