pub struct RecursionLimiter {
pub visited: bool,
pub live: bool,
/* private fields */
}Expand description
Prevents infinite recursion during Debug::fmt, JSON.stringify, and other conversions.
This uses a thread local, so is not safe to use where the object graph will be traversed by
multiple threads!
Fields§
§visited: boolIf this JsObject has been visited before in the graph, but not in the current branch.
live: boolIf this JsObject has been visited in the current branch of the graph.
Implementations§
Source§impl RecursionLimiter
impl RecursionLimiter
Sourcepub fn new(o: &JsObject) -> Self
pub fn new(o: &JsObject) -> Self
Determines if the specified JsObject has been visited, and returns a struct that will free it when dropped.
This is done by maintaining a thread-local hashset containing the pointers of JsObject values that have been
visited. The first JsObject visited will clear the hashset, while any others will check if they are contained
by the hashset.
Trait Implementations§
Source§impl Debug for RecursionLimiter
impl Debug for RecursionLimiter
Auto Trait Implementations§
impl Freeze for RecursionLimiter
impl RefUnwindSafe for RecursionLimiter
impl Send for RecursionLimiter
impl Sync for RecursionLimiter
impl Unpin for RecursionLimiter
impl UnwindSafe for RecursionLimiter
Blanket Implementations§
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