From f279c52b503e9dacb558d8a46a75b42bc5222ee4 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Mon, 29 Apr 2019 00:12:36 +0200 Subject: =?UTF-8?q?Simple=20dynamic,=20scoped=20function=20parsing=20?= =?UTF-8?q?=F0=9F=93=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/engine/mod.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'src/engine') diff --git a/src/engine/mod.rs b/src/engine/mod.rs index ea81053b..37fce8dc 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -14,13 +14,13 @@ pub use size::Size; /// The core typesetting engine, transforming an abstract syntax tree into a document. -pub struct Engine<'t> { +pub struct Engine<'a> { // Input - tree: &'t SyntaxTree<'t>, - ctx: &'t Context<'t>, + tree: &'a SyntaxTree, + ctx: &'a Context<'a>, // Internal - font_loader: FontLoader<'t>, + font_loader: FontLoader<'a>, // Output text_commands: Vec, @@ -34,9 +34,9 @@ pub struct Engine<'t> { italic: bool, } -impl<'t> Engine<'t> { +impl<'a> Engine<'a> { /// Create a new generator from a syntax tree. - pub(crate) fn new(tree: &'t SyntaxTree<'t>, context: &'t Context<'t>) -> Engine<'t> { + pub(crate) fn new(tree: &'a SyntaxTree, context: &'a Context<'a>) -> Engine<'a> { Engine { tree, ctx: context, @@ -211,30 +211,30 @@ impl<'t> Engine<'t> { } /// Serves matching fonts given a query. -struct FontLoader<'t> { +struct FontLoader<'a> { /// The context containing the used font providers. - context: &'t Context<'t>, + context: &'a Context<'a>, /// All available fonts indexed by provider. - provider_fonts: Vec<&'t [FontInfo]>, + provider_fonts: Vec<&'a [FontInfo]>, /// The internal state. - state: RefCell>, + state: RefCell>, } /// Internal state of the font loader (wrapped in a RefCell). -struct FontLoaderState<'t> { +struct FontLoaderState<'a> { /// The loaded fonts along with their external indices. fonts: Vec<(Option, Font)>, /// Allows to retrieve cached results for queries. - query_cache: HashMap, usize>, + query_cache: HashMap, usize>, /// Allows to lookup fonts by their infos. - info_cache: HashMap<&'t FontInfo, usize>, + info_cache: HashMap<&'a FontInfo, usize>, /// Indexed by outside and indices maps to internal indices. inner_index: Vec, } -impl<'t> FontLoader<'t> { +impl<'a> FontLoader<'a> { /// Create a new font loader. - pub fn new(context: &'t Context<'t>) -> FontLoader { + pub fn new(context: &'a Context<'a>) -> FontLoader { let provider_fonts = context.font_providers.iter() .map(|prov| prov.available()).collect(); @@ -251,7 +251,7 @@ impl<'t> FontLoader<'t> { } /// Return the best matching font and it's index (if there is any) given the query. - pub fn get(&self, query: FontQuery<'t>) -> Option<(usize, Ref)> { + pub fn get(&self, query: FontQuery<'a>) -> Option<(usize, Ref)> { // Check if we had the exact same query before. let state = self.state.borrow(); if let Some(&index) = state.query_cache.get(&query) { -- cgit v1.2.3