diff options
| author | Martin <mhaug@live.de> | 2021-08-19 15:07:11 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-19 15:07:11 +0200 |
| commit | fdab7158c91c52a4ace211c804fdd8e9110f56de (patch) | |
| tree | 7ec34f942bc89b2ade554618648825654a587ace /src/lib.rs | |
| parent | c44ecbfbd2706bf8e09728f2c85135aa2299d542 (diff) | |
Pattern properties (#42)
Included in this package are:
* Code review I: The unnamed review.
* Code Review II: How I met your review.
* Code Review III: Code, the final frontier. These are the voyages of the USS Review ...
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 17 |
1 files changed, 13 insertions, 4 deletions
@@ -49,15 +49,15 @@ pub mod util; use std::rc::Rc; use crate::diag::TypResult; -use crate::eval::{Scope, State, Module}; -use crate::syntax::SyntaxTree; +use crate::eval::{Module, Scope, State}; use crate::font::FontStore; use crate::image::ImageStore; #[cfg(feature = "layout-cache")] -use crate::layout::LayoutCache; +use crate::layout::{EvictionStrategy, LayoutCache}; use crate::layout::{Frame, LayoutTree}; use crate::loading::Loader; use crate::source::{SourceId, SourceStore}; +use crate::syntax::SyntaxTree; /// The core context which holds the loader, configuration and cached artifacts. pub struct Context { @@ -141,6 +141,8 @@ impl Context { pub struct ContextBuilder { std: Option<Scope>, state: Option<State>, + #[cfg(feature = "layout-cache")] + policy: Option<EvictionStrategy>, } impl ContextBuilder { @@ -157,6 +159,13 @@ impl ContextBuilder { self } + /// The policy for eviction of the layout cache. + #[cfg(feature = "layout-cache")] + pub fn policy(mut self, policy: EvictionStrategy) -> Self { + self.policy = Some(policy); + self + } + /// Finish building the context by providing the `loader` used to load /// fonts, images, source files and other resources. pub fn build(self, loader: Rc<dyn Loader>) -> Context { @@ -166,7 +175,7 @@ impl ContextBuilder { images: ImageStore::new(Rc::clone(&loader)), loader, #[cfg(feature = "layout-cache")] - layouts: LayoutCache::new(), + layouts: LayoutCache::new(self.policy.unwrap_or_default()), std: self.std.unwrap_or(library::new()), state: self.state.unwrap_or_default(), } |
