Refine inlining.
This commit is contained in:
parent
82b64e9c7a
commit
6c777e68d3
@ -36,6 +36,8 @@ fn main() -> Result<(), Box<EvalAltResult>> {
|
||||
type Item = i64;
|
||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
vec![self.x - 1, self.x, self.x + 1].into_iter()
|
||||
}
|
||||
|
@ -157,7 +157,6 @@ impl Deref for Expression<'_> {
|
||||
type Target = Expr;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.0
|
||||
}
|
||||
|
@ -77,6 +77,7 @@ pub struct DefinitionsConfig {
|
||||
|
||||
impl Default for DefinitionsConfig {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
write_headers: false,
|
||||
|
@ -75,6 +75,7 @@ impl Limits {
|
||||
|
||||
impl Default for Limits {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ pub struct AST {
|
||||
|
||||
impl Default for AST {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::empty()
|
||||
}
|
||||
|
@ -75,8 +75,8 @@ impl CustomExpr {
|
||||
/// Is this custom syntax self-terminated (i.e. no need for a semicolon terminator)?
|
||||
///
|
||||
/// A self-terminated custom syntax always ends in `$block$`, `}` or `;`
|
||||
#[must_use]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub const fn is_self_terminated(&self) -> bool {
|
||||
self.self_terminated
|
||||
}
|
||||
@ -281,7 +281,6 @@ impl<F: Float> Deref for FloatWrapper<F> {
|
||||
type Target = F;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
@ -290,7 +289,6 @@ impl<F: Float> Deref for FloatWrapper<F> {
|
||||
#[cfg(not(feature = "no_float"))]
|
||||
impl<F: Float> DerefMut for FloatWrapper<F> {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.0
|
||||
}
|
||||
@ -447,6 +445,7 @@ pub enum Expr {
|
||||
|
||||
impl Default for Expr {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::Unit(Position::NONE)
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ impl Deref for Ident {
|
||||
type Target = ImmutableString;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.name
|
||||
}
|
||||
@ -48,7 +47,6 @@ impl Deref for Ident {
|
||||
|
||||
impl DerefMut for Ident {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.name
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ impl Deref for Namespace {
|
||||
type Target = StaticVec<Ident>;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.path
|
||||
}
|
||||
@ -80,7 +79,6 @@ impl Deref for Namespace {
|
||||
|
||||
impl DerefMut for Namespace {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.path
|
||||
}
|
||||
|
@ -209,6 +209,7 @@ impl IntoIterator for RangeCase {
|
||||
type IntoIter = Box<dyn Iterator<Item = Self::Item>>;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
match self {
|
||||
Self::ExclusiveInt(r, ..) => Box::new(r),
|
||||
@ -426,7 +427,6 @@ impl Deref for StmtBlock {
|
||||
type Target = StmtBlockContainer;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.block
|
||||
}
|
||||
@ -434,7 +434,6 @@ impl Deref for StmtBlock {
|
||||
|
||||
impl DerefMut for StmtBlock {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
&mut self.block
|
||||
}
|
||||
@ -607,6 +606,7 @@ pub enum Stmt {
|
||||
|
||||
impl Default for Stmt {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::Noop(Position::NONE)
|
||||
}
|
||||
|
@ -190,6 +190,7 @@ impl fmt::Debug for Engine {
|
||||
|
||||
impl Default for Engine {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -48,6 +48,7 @@ pub enum DebuggerCommand {
|
||||
|
||||
impl Default for DebuggerCommand {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::Continue
|
||||
}
|
||||
|
@ -316,7 +316,6 @@ impl IntoIterator for GlobalRuntimeState<'_> {
|
||||
std::iter::Rev<smallvec::IntoIter<[crate::Shared<crate::Module>; 3]>>,
|
||||
>;
|
||||
|
||||
#[inline]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.keys
|
||||
.into_iter()
|
||||
@ -333,10 +332,8 @@ impl<'a> IntoIterator for &'a GlobalRuntimeState<'_> {
|
||||
std::iter::Rev<std::slice::Iter<'a, crate::Shared<crate::Module>>>,
|
||||
>;
|
||||
|
||||
#[inline]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
let x = self.keys.iter().rev().zip(self.modules.iter().rev());
|
||||
x
|
||||
self.keys.iter().rev().zip(self.modules.iter().rev())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,7 +399,6 @@ impl Deref for Target<'_> {
|
||||
type Target = Dynamic;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Dynamic {
|
||||
match self {
|
||||
Self::RefMut(r) => r,
|
||||
@ -425,7 +424,6 @@ impl AsRef<Dynamic> for Target<'_> {
|
||||
|
||||
impl DerefMut for Target<'_> {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Dynamic {
|
||||
match self {
|
||||
Self::RefMut(r) => r,
|
||||
|
@ -46,6 +46,7 @@ pub trait Func<ARGS, RET> {
|
||||
/// func(123, "hello")? == false; // call the anonymous function
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
#[must_use]
|
||||
fn create_from_ast(self, ast: AST, entry_point: &str) -> Self::Output;
|
||||
|
||||
/// Create a Rust closure from a script.
|
||||
@ -79,6 +80,7 @@ pub trait Func<ARGS, RET> {
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
#[must_use]
|
||||
fn create_from_script(self, script: &str, entry_point: &str) -> ParseResult<Self::Output>;
|
||||
}
|
||||
|
||||
|
@ -41,6 +41,7 @@ pub struct StraightHasher(u64);
|
||||
|
||||
impl Hasher for StraightHasher {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn finish(&self) -> u64 {
|
||||
self.0
|
||||
}
|
||||
@ -66,6 +67,7 @@ impl BuildHasher for StraightHasherBuilder {
|
||||
type Hasher = StraightHasher;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn build_hasher(&self) -> Self::Hasher {
|
||||
StraightHasher(ALT_ZERO_HASH)
|
||||
}
|
||||
|
@ -86,8 +86,11 @@ pub trait RegisterNativeFunction<ARGS, RET, RESULT> {
|
||||
/// _(metadata)_ Get the type name of this function's return value.
|
||||
/// Exported under the `metadata` feature only.
|
||||
#[cfg(feature = "metadata")]
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn return_type_name() -> &'static str;
|
||||
fn return_type_name() -> &'static str {
|
||||
std::any::type_name::<RET>()
|
||||
}
|
||||
}
|
||||
|
||||
const EXPECT_ARGS: &str = "arguments";
|
||||
@ -138,7 +141,6 @@ macro_rules! def_register {
|
||||
#[inline(always)] fn param_types() -> Box<[TypeId]> { vec![$(TypeId::of::<$par>()),*].into_boxed_slice() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { vec![$(std::any::type_name::<$param>()),*].into_boxed_slice() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::<RET>() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { std::any::type_name::<RET>() }
|
||||
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
|
||||
CallableFunction::$abi(Shared::new(move |_ctx: NativeCallContext, args: &mut FnCallArgs| {
|
||||
// The arguments are assumed to be of the correct number and types!
|
||||
@ -164,7 +166,6 @@ macro_rules! def_register {
|
||||
#[inline(always)] fn param_types() -> Box<[TypeId]> { vec![$(TypeId::of::<$par>()),*].into_boxed_slice() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn param_names() -> Box<[&'static str]> { vec![$(std::any::type_name::<$param>()),*].into_boxed_slice() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn return_type() -> TypeId { TypeId::of::<RET>() }
|
||||
#[cfg(feature = "metadata")] #[inline(always)] fn return_type_name() -> &'static str { std::any::type_name::<RET>() }
|
||||
#[inline(always)] fn into_callable_function(self) -> CallableFunction {
|
||||
CallableFunction::$abi(Shared::new(move |ctx: NativeCallContext, args: &mut FnCallArgs| {
|
||||
// The arguments are assumed to be of the correct number and types!
|
||||
|
@ -251,13 +251,10 @@ impl Engine {
|
||||
// Then check sub-modules
|
||||
|| self.global_sub_modules.values().any(|m| m.contains_qualified_fn(hash_script));
|
||||
|
||||
if !result {
|
||||
if cache.filter.is_absent(hash_script) {
|
||||
cache.filter.mark(hash_script);
|
||||
} else {
|
||||
if !result && !cache.filter.is_absent_and_set(hash_script) {
|
||||
// Do not cache "one-hit wonders"
|
||||
cache.map.insert(hash_script, None);
|
||||
}
|
||||
}
|
||||
|
||||
result
|
||||
}
|
||||
|
@ -196,6 +196,7 @@ pub struct Module {
|
||||
|
||||
impl Default for Module {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ impl ModuleResolversCollection {
|
||||
/// ```
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
pub const fn new() -> Self {
|
||||
Self(Vec::new())
|
||||
}
|
||||
/// Append a [module resolver][ModuleResolver] to the end.
|
||||
@ -112,6 +112,7 @@ impl IntoIterator for ModuleResolversCollection {
|
||||
type IntoIter = IntoIter<Box<dyn ModuleResolver>>;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.into_iter()
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ pub struct FileModuleResolver {
|
||||
|
||||
impl Default for FileModuleResolver {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -134,6 +134,7 @@ impl IntoIterator for StaticModuleResolver {
|
||||
type IntoIter = IntoIter<SmartString, Shared<Module>>;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.into_iter()
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ pub enum OptimizationLevel {
|
||||
|
||||
impl Default for OptimizationLevel {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::Simple
|
||||
}
|
||||
|
@ -45,11 +45,14 @@ pub use time_basic::BasicTimePackage;
|
||||
pub trait Package {
|
||||
/// Initialize the package.
|
||||
/// Functions should be registered into `module` here.
|
||||
#[cold]
|
||||
fn init(module: &mut Module);
|
||||
|
||||
/// Initialize the package with an [`Engine`].
|
||||
///
|
||||
/// Perform tasks such as registering custom operators/syntax.
|
||||
#[cold]
|
||||
#[inline]
|
||||
#[allow(unused_variables)]
|
||||
fn init_engine(engine: &mut Engine) {}
|
||||
|
||||
@ -65,6 +68,8 @@ pub trait Package {
|
||||
///
|
||||
/// package.register_into_engine(&mut engine);
|
||||
/// ```
|
||||
#[cold]
|
||||
#[inline]
|
||||
fn register_into_engine(&self, engine: &mut Engine) -> &Self {
|
||||
Self::init_engine(engine);
|
||||
engine.register_global_module(self.as_shared_module());
|
||||
@ -84,6 +89,8 @@ pub trait Package {
|
||||
/// package.register_into_engine_as(&mut engine, "core");
|
||||
/// ```
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[cold]
|
||||
#[inline]
|
||||
fn register_into_engine_as(&self, engine: &mut Engine, name: &str) -> &Self {
|
||||
Self::init_engine(engine);
|
||||
engine.register_static_module(name, self.as_shared_module());
|
||||
@ -133,7 +140,6 @@ macro_rules! def_package {
|
||||
fn as_shared_module(&self) -> $crate::Shared<$crate::Module> {
|
||||
self.0.clone()
|
||||
}
|
||||
#[inline]
|
||||
fn init($lib: &mut $crate::Module) {
|
||||
$($(
|
||||
$(#[$base_meta])* { <$base_pkg>::init($lib); }
|
||||
@ -141,7 +147,6 @@ macro_rules! def_package {
|
||||
|
||||
$block
|
||||
}
|
||||
#[inline]
|
||||
fn init_engine(_engine: &mut $crate::Engine) {
|
||||
$($(
|
||||
$(#[$base_meta])* { <$base_pkg>::init_engine(_engine); }
|
||||
@ -156,6 +161,7 @@ macro_rules! def_package {
|
||||
|
||||
impl Default for $package {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
@ -193,12 +199,16 @@ macro_rules! def_package {
|
||||
}
|
||||
|
||||
impl Default for $package {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl $package {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
let mut module = $root::Module::new();
|
||||
<Self as $root::packages::Package>::init(&mut module);
|
||||
@ -229,12 +239,16 @@ macro_rules! def_package {
|
||||
}
|
||||
|
||||
impl Default for $package {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl $package {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn new() -> Self {
|
||||
let mut module = $root::Module::new();
|
||||
<Self as $root::packages::Package>::init(&mut module);
|
||||
|
@ -110,7 +110,7 @@ impl fmt::Debug for ParseState<'_> {
|
||||
|
||||
impl<'e> ParseState<'e> {
|
||||
/// Create a new [`ParseState`].
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
engine: &Engine,
|
||||
@ -183,7 +183,6 @@ impl<'e> ParseState<'e> {
|
||||
///
|
||||
/// * `is_func_name`: `true` if the variable is actually the name of a function
|
||||
/// (in which case it will be converted into a function pointer).
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn access_var(
|
||||
&mut self,
|
||||
@ -235,7 +234,6 @@ impl<'e> ParseState<'e> {
|
||||
///
|
||||
/// Panics when called under `no_module`.
|
||||
#[cfg(not(feature = "no_module"))]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn find_module(&self, name: &str) -> Option<NonZeroUsize> {
|
||||
self.imports
|
||||
@ -258,7 +256,7 @@ impl<'e> ParseState<'e> {
|
||||
|
||||
/// Get an interned property getter, creating one if it is not yet interned.
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_interned_getter(
|
||||
&mut self,
|
||||
@ -273,7 +271,7 @@ impl<'e> ParseState<'e> {
|
||||
|
||||
/// Get an interned property setter, creating one if it is not yet interned.
|
||||
#[cfg(not(feature = "no_object"))]
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn get_interned_setter(
|
||||
&mut self,
|
||||
@ -313,7 +311,7 @@ struct ParseSettings {
|
||||
|
||||
impl ParseSettings {
|
||||
/// Create a new `ParseSettings` with one higher expression level.
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn level_up(&self) -> Self {
|
||||
Self {
|
||||
@ -417,7 +415,6 @@ impl Expr {
|
||||
}
|
||||
|
||||
/// Make sure that the next expression is not a statement expression (i.e. wrapped in `{}`).
|
||||
#[inline]
|
||||
fn ensure_not_statement_expr(
|
||||
input: &mut TokenStream,
|
||||
type_name: &(impl ToString + ?Sized),
|
||||
@ -429,7 +426,6 @@ fn ensure_not_statement_expr(
|
||||
}
|
||||
|
||||
/// Make sure that the next expression is not a mis-typed assignment (i.e. `a = b` instead of `a == b`).
|
||||
#[inline]
|
||||
fn ensure_not_assignment(input: &mut TokenStream) -> ParseResult<()> {
|
||||
match input.peek().expect(NEVER_ENDS) {
|
||||
(Token::Equals, pos) => Err(LexError::ImproperSymbol(
|
||||
@ -446,7 +442,6 @@ fn ensure_not_assignment(input: &mut TokenStream) -> ParseResult<()> {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if the next token is not the expected one.
|
||||
#[inline]
|
||||
fn eat_token(input: &mut TokenStream, expected_token: Token) -> Position {
|
||||
let (t, pos) = input.next().expect(NEVER_ENDS);
|
||||
|
||||
@ -462,7 +457,6 @@ fn eat_token(input: &mut TokenStream, expected_token: Token) -> Position {
|
||||
}
|
||||
|
||||
/// Match a particular [token][Token], consuming it if matched.
|
||||
#[inline]
|
||||
fn match_token(input: &mut TokenStream, token: Token) -> (bool, Position) {
|
||||
let (t, pos) = input.peek().expect(NEVER_ENDS);
|
||||
if *t == token {
|
||||
@ -473,7 +467,6 @@ fn match_token(input: &mut TokenStream, token: Token) -> (bool, Position) {
|
||||
}
|
||||
|
||||
/// Parse a variable name.
|
||||
#[inline]
|
||||
fn parse_var_name(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
||||
match input.next().expect(NEVER_ENDS) {
|
||||
// Variable name
|
||||
@ -491,7 +484,6 @@ fn parse_var_name(input: &mut TokenStream) -> ParseResult<(SmartString, Position
|
||||
|
||||
/// Parse a symbol.
|
||||
#[cfg(not(feature = "no_custom_syntax"))]
|
||||
#[inline]
|
||||
fn parse_symbol(input: &mut TokenStream) -> ParseResult<(SmartString, Position)> {
|
||||
match input.next().expect(NEVER_ENDS) {
|
||||
// Symbol
|
||||
|
@ -32,7 +32,7 @@ pub struct TokenizerControlBlock {
|
||||
|
||||
impl TokenizerControlBlock {
|
||||
/// Create a new `TokenizerControlBlock`.
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
@ -97,7 +97,7 @@ impl Position {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `line` is zero.
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn new(line: u16, position: u16) -> Self {
|
||||
assert!(line != 0, "line cannot be zero");
|
||||
@ -220,6 +220,7 @@ impl Position {
|
||||
|
||||
impl Default for Position {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::START
|
||||
}
|
||||
@ -299,6 +300,8 @@ pub struct Span {
|
||||
}
|
||||
|
||||
impl Default for Span {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::NONE
|
||||
}
|
||||
@ -315,7 +318,7 @@ impl Span {
|
||||
Self { start, end }
|
||||
}
|
||||
/// Is this [`Span`] non-existent?
|
||||
#[inline(always)]
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub const fn is_none(&self) -> bool {
|
||||
self.start.is_none() && self.end.is_none()
|
||||
|
@ -153,7 +153,6 @@ impl<'d, T: Any + Clone> Deref for DynamicWriteLock<'d, T> {
|
||||
type Target = T;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
match self.0 {
|
||||
DynamicWriteLockInner::Reference(ref reference) => *reference,
|
||||
@ -165,7 +164,6 @@ impl<'d, T: Any + Clone> Deref for DynamicWriteLock<'d, T> {
|
||||
|
||||
impl<'d, T: Any + Clone> DerefMut for DynamicWriteLock<'d, T> {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||
match self.0 {
|
||||
DynamicWriteLockInner::Reference(ref mut reference) => *reference,
|
||||
|
@ -53,7 +53,6 @@ impl Deref for ImmutableString {
|
||||
type Target = SmartString;
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.0
|
||||
}
|
||||
@ -148,6 +147,7 @@ impl FromStr for ImmutableString {
|
||||
type Err = ();
|
||||
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let s: SmartString = s.into();
|
||||
Ok(Self(s.into()))
|
||||
@ -156,6 +156,7 @@ impl FromStr for ImmutableString {
|
||||
|
||||
impl FromIterator<char> for ImmutableString {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn from_iter<T: IntoIterator<Item = char>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().collect::<SmartString>().into())
|
||||
}
|
||||
@ -163,6 +164,7 @@ impl FromIterator<char> for ImmutableString {
|
||||
|
||||
impl<'a> FromIterator<&'a char> for ImmutableString {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn from_iter<T: IntoIterator<Item = &'a char>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().copied().collect::<SmartString>().into())
|
||||
}
|
||||
@ -170,6 +172,7 @@ impl<'a> FromIterator<&'a char> for ImmutableString {
|
||||
|
||||
impl<'a> FromIterator<&'a str> for ImmutableString {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn from_iter<T: IntoIterator<Item = &'a str>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().collect::<SmartString>().into())
|
||||
}
|
||||
@ -177,6 +180,7 @@ impl<'a> FromIterator<&'a str> for ImmutableString {
|
||||
|
||||
impl FromIterator<String> for ImmutableString {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn from_iter<T: IntoIterator<Item = String>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().collect::<SmartString>().into())
|
||||
}
|
||||
@ -184,6 +188,7 @@ impl FromIterator<String> for ImmutableString {
|
||||
|
||||
impl FromIterator<SmartString> for ImmutableString {
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn from_iter<T: IntoIterator<Item = SmartString>>(iter: T) -> Self {
|
||||
Self(iter.into_iter().collect::<SmartString>().into())
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ pub struct StringsInterner<'a> {
|
||||
|
||||
impl Default for StringsInterner<'_> {
|
||||
#[inline(always)]
|
||||
#[must_use]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ impl IntoIterator for Scope<'_> {
|
||||
type Item = (String, Dynamic, Vec<Identifier>);
|
||||
type IntoIter = Box<dyn Iterator<Item = Self::Item>>;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
Box::new(
|
||||
self.values
|
||||
@ -143,7 +143,7 @@ impl<'a> IntoIterator for &'a Scope<'_> {
|
||||
type Item = (&'a Identifier, &'a Dynamic, &'a Vec<Identifier>);
|
||||
type IntoIter = Box<dyn Iterator<Item = Self::Item> + 'a>;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
Box::new(
|
||||
self.values
|
||||
@ -719,7 +719,6 @@ impl Scope<'_> {
|
||||
scope
|
||||
}
|
||||
/// Get an iterator to entries in the [`Scope`].
|
||||
#[inline]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) fn into_iter(self) -> impl Iterator<Item = (Identifier, Dynamic, Vec<Identifier>)> {
|
||||
self.names
|
||||
|
@ -49,6 +49,8 @@ fn build_type() -> Result<(), Box<EvalAltResult>> {
|
||||
type Item = INT;
|
||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
vec![self.x, self.y, self.z].into_iter()
|
||||
}
|
||||
|
@ -337,6 +337,8 @@ impl IntoIterator for MyIterableType {
|
||||
type Item = char;
|
||||
type IntoIter = std::vec::IntoIter<Self::Item>;
|
||||
|
||||
#[inline]
|
||||
#[must_use]
|
||||
fn into_iter(self) -> Self::IntoIter {
|
||||
self.0.chars().collect::<Vec<_>>().into_iter()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user