Add lifetime.
This commit is contained in:
parent
99bcd8497a
commit
493c4a71ff
@ -46,7 +46,7 @@ pub struct ParseState<'e> {
|
|||||||
/// Input stream buffer containing the next character to read.
|
/// Input stream buffer containing the next character to read.
|
||||||
pub tokenizer_control: TokenizerControl,
|
pub tokenizer_control: TokenizerControl,
|
||||||
/// Interned strings.
|
/// Interned strings.
|
||||||
interned_strings: StringsInterner,
|
interned_strings: StringsInterner<'e>,
|
||||||
/// External [scope][Scope] with constants.
|
/// External [scope][Scope] with constants.
|
||||||
pub scope: &'e Scope<'e>,
|
pub scope: &'e Scope<'e>,
|
||||||
/// Global runtime state.
|
/// Global runtime state.
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
use crate::{Identifier, ImmutableString};
|
use crate::{Identifier, ImmutableString};
|
||||||
#[cfg(feature = "no_std")]
|
#[cfg(feature = "no_std")]
|
||||||
use std::prelude::v1::*;
|
use std::prelude::v1::*;
|
||||||
use std::{collections::BTreeMap, ops::AddAssign};
|
use std::{collections::BTreeMap, marker::PhantomData, ops::AddAssign};
|
||||||
|
|
||||||
/// _(internals)_ A factory of identifiers from text strings.
|
/// _(internals)_ A factory of identifiers from text strings.
|
||||||
/// Exported under the `internals` feature only.
|
/// Exported under the `internals` feature only.
|
||||||
///
|
///
|
||||||
/// Normal identifiers, property getters and setters are interned separately.
|
/// Normal identifiers, property getters and setters are interned separately.
|
||||||
#[derive(Debug, Clone, Default, Hash)]
|
#[derive(Debug, Clone, Default, Hash)]
|
||||||
pub struct StringsInterner {
|
pub struct StringsInterner<'a> {
|
||||||
/// Normal strings.
|
/// Normal strings.
|
||||||
strings: BTreeMap<Identifier, ImmutableString>,
|
strings: BTreeMap<Identifier, ImmutableString>,
|
||||||
/// Property getters.
|
/// Property getters.
|
||||||
@ -17,9 +17,11 @@ pub struct StringsInterner {
|
|||||||
/// Property setters.
|
/// Property setters.
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
setters: BTreeMap<Identifier, ImmutableString>,
|
setters: BTreeMap<Identifier, ImmutableString>,
|
||||||
|
/// Take care of the lifetime parameter.
|
||||||
|
dummy: PhantomData<&'a ()>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl StringsInterner {
|
impl StringsInterner<'_> {
|
||||||
/// Create a new [`StringsInterner`].
|
/// Create a new [`StringsInterner`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[must_use]
|
#[must_use]
|
||||||
@ -30,6 +32,7 @@ impl StringsInterner {
|
|||||||
getters: BTreeMap::new(),
|
getters: BTreeMap::new(),
|
||||||
#[cfg(not(feature = "no_object"))]
|
#[cfg(not(feature = "no_object"))]
|
||||||
setters: BTreeMap::new(),
|
setters: BTreeMap::new(),
|
||||||
|
dummy: PhantomData,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// Get an identifier from a text string and prefix, adding it to the interner if necessary.
|
/// Get an identifier from a text string and prefix, adding it to the interner if necessary.
|
||||||
@ -69,7 +72,7 @@ impl StringsInterner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<Self> for StringsInterner {
|
impl AddAssign<Self> for StringsInterner<'_> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn add_assign(&mut self, rhs: Self) {
|
fn add_assign(&mut self, rhs: Self) {
|
||||||
self.strings.extend(rhs.strings.into_iter());
|
self.strings.extend(rhs.strings.into_iter());
|
||||||
@ -80,7 +83,7 @@ impl AddAssign<Self> for StringsInterner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AddAssign<&Self> for StringsInterner {
|
impl AddAssign<&Self> for StringsInterner<'_> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn add_assign(&mut self, rhs: &Self) {
|
fn add_assign(&mut self, rhs: &Self) {
|
||||||
self.strings
|
self.strings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user