Function serenity::utils::with_cache [−][src]
pub fn with_cache<T, F>(f: F) -> T where
F: Fn(&Cache) -> T,
A function for doing automatic read
ing (and the releasing of the guard as well)
This is particularly useful if you just want to use the cache for this one time,
or don't want to be messing with the RwLock
directly.
Examples
Return the bot's id
ⓘThis example is not tested
use serenity::utils; // assuming that the id is `1234`: assert_eq!(1234, utils::with_cache(|cache| cache.user.id));