Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
laurmaedje committed Mar 6, 2024
1 parent a8484a2 commit c211f63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 7 additions & 1 deletion macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ use syn::{parse_quote, Error, Result};
/// basic mutable arguments, but it cannot determine all sources of impurity,
/// so this is your responsibility.
///
/// - The output of a memoized function must be `Send` and `Sync` because it is
/// stored in the global cache.
///
/// Furthermore, memoized functions cannot use destructuring patterns in their
/// arguments.
///
Expand Down Expand Up @@ -118,11 +121,14 @@ pub fn memoize(_: BoundaryStream, stream: BoundaryStream) -> BoundaryStream {
/// [`Hash`](std::hash::Hash) and **must feed all the information they expose
/// to the hasher**. Otherwise, memoized results might get reused invalidly.
///
/// - The arguments to a tracked method must be `Send` and `Sync` because they
/// are stored in the global cache.
///
/// Furthermore:
/// - Tracked methods cannot be generic.
/// - They cannot be `unsafe`, `async` or `const`.
/// - They must take an `&self` or `&mut self` parameter.
/// - Their arguments must implement [`ToOwned`](std::borrow::ToOwned).
/// - Their arguments must implement [`ToOwned`].
/// - Their return values must implement [`Hash`](std::hash::Hash).
/// - They cannot use destructuring patterns in their arguments.
///
Expand Down
5 changes: 1 addition & 4 deletions src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,12 @@ where
output
}

/// Evict the cache.
/// Evict the global cache.
///
/// This removes all memoized results from the cache whose age is larger than or
/// equal to `max_age`. The age of a result grows by one during each eviction
/// and is reset to zero when the result produces a cache hit. Set `max_age` to
/// zero to completely clear the cache.
///
/// Comemo's cache is thread-local, meaning that this only evicts this thread's
/// cache.
pub fn evict(max_age: usize) {
for subevict in EVICTORS.read().iter() {
subevict(max_age);
Expand Down

0 comments on commit c211f63

Please sign in to comment.