Struct Cache
struct Cache { ... }
A cache represents mutable state that a one-pass DFA requires during a
search.
For a given one-pass DFA, its corresponding cache may be created either via
DFA::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 one-pass DFA from which it was
created. It may only be used with that one-pass DFA. A cache and its
allocations may be re-purposed via Cache::reset, in which case, it can
only be used with the new one-pass DFA (and not the old one).
Implementations
impl Cache
fn new(re: &DFA) -> CacheCreate a new
onepass::DFAcache.A potentially more convenient routine to create a cache is
DFA::create_cache, as it does not require also importing theCachetype.If you want to reuse the returned
Cachewith some other one-pass DFA, then you must callCache::resetwith the desired one-pass DFA.fn reset(self: &mut Self, re: &DFA)Reset this cache such that it can be used for searching with a different
onepass::DFA.A cache reset permits reusing memory already allocated in this cache with a different one-pass DFA.
Example
This shows how to re-purpose a cache for use with a different one-pass DFA.
# if cfg! // miri takes too long use ; let re1 = DFAnew?; let re2 = DFAnew?; let mut caps1 = re1.create_captures; let mut caps2 = re2.create_captures; 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 one-pass DFA we'd like to use it with. // // Similarly, after this reset, using the cache with 're1' is also not // allowed. re2.reset_cache; assert_eq!; # Ok::fn memory_usage(self: &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>().
impl Clone for Cache
fn clone(self: &Self) -> Cache
impl Debug for Cache
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
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
impl<T> Any for Cache
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Cache
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Cache
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for Cache
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for Cache
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Cache
fn to_owned(self: &Self) -> Tfn clone_into(self: &Self, target: &mut T)
impl<T, U> Into for Cache
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Cache
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Cache
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>