Struct Cache
pub struct Cache { /* private fields */ }
A cache represents mutable state that a BoundedBacktracker requires
during a search.
For a given BoundedBacktracker, its corresponding cache may be created
either via BoundedBacktracker::create_cache, or via Cache::new.
They are equivalent in every way, except the former does not require
explicitly importing Cache.
A particular Cache is coupled with the BoundedBacktracker from which
it was created. It may only be used with that BoundedBacktracker. A cache
and its allocations may be re-purposed via Cache::reset, in which case,
it can only be used with the new BoundedBacktracker (and not the old
one).
Implementations
impl Cache
fn new(re: &BoundedBacktracker) -> CacheCreate a new
BoundedBacktrackercache.A potentially more convenient routine to create a cache is
BoundedBacktracker::create_cache, as it does not require also importing theCachetype.If you want to reuse the returned
Cachewith some otherBoundedBacktracker, then you must callCache::resetwith the desiredBoundedBacktracker.fn reset(&mut self, re: &BoundedBacktracker)Reset this cache such that it can be used for searching with different
BoundedBacktracker.A cache reset permits reusing memory already allocated in this cache with a different
BoundedBacktracker.Example
This shows how to re-purpose a cache for use with a different
BoundedBacktracker.# if cfg! // miri takes too long use ; let re1 = new?; let re2 = new?; let mut cache = re1.create_cache; assert_eq!; // Using 'cache' with re2 is not allowed. It may result in panics or // incorrect results. In order to re-purpose the cache, we must reset // it with the BoundedBacktracker we'd like to use it with. // // Similarly, after this reset, using the cache with 're1' is also not // allowed. cache.reset; assert_eq!; # Ok::fn memory_usage(&self) -> usizeReturns the heap memory usage, in bytes, of this cache.
This does not include the stack size used up by this cache. To compute that, use
std::mem::size_of::<Cache>().
Trait Implementations
impl Clone for Cache
fn clone(&self) -> Self
impl Debug for Cache
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl Freeze for Cache
impl RefUnwindSafe for Cache
impl Send for Cache
impl Sync for Cache
impl Unpin for Cache
impl UnsafeUnpin for Cache
impl UnwindSafe for Cache
Blanket Implementations
impl<T> Any for Cache
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Cache
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Cache
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Cache
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Cache
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Cache
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Cache
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Cache
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Cache
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>