Reduce unnecessary generics.

This commit is contained in:
Stephen Chung
2022-10-20 15:31:57 +08:00
parent f8888c83e7
commit c24794187f
8 changed files with 88 additions and 30 deletions

View File

@@ -5,6 +5,7 @@ use crate::{Dynamic, FnNamespace, Identifier, Position};
#[cfg(feature = "no_std")]
use std::prelude::v1::*;
use std::{
borrow::Borrow,
fmt,
hash::Hash,
ops::{Add, AddAssign},
@@ -919,6 +920,14 @@ impl<A: Into<Self>> AddAssign<A> for AST {
}
}
impl Borrow<[Stmt]> for AST {
#[inline(always)]
#[must_use]
fn borrow(&self) -> &[Stmt] {
self.statements()
}
}
impl AsRef<[Stmt]> for AST {
#[inline(always)]
#[must_use]
@@ -927,6 +936,15 @@ impl AsRef<[Stmt]> for AST {
}
}
#[cfg(not(feature = "no_function"))]
impl Borrow<crate::Module> for AST {
#[inline(always)]
#[must_use]
fn borrow(&self) -> &crate::Module {
&self.shared_lib()
}
}
#[cfg(not(feature = "no_function"))]
impl AsRef<crate::Module> for AST {
#[inline(always)]
@@ -936,6 +954,15 @@ impl AsRef<crate::Module> for AST {
}
}
#[cfg(not(feature = "no_function"))]
impl Borrow<crate::Shared<crate::Module>> for AST {
#[inline(always)]
#[must_use]
fn borrow(&self) -> &crate::Shared<crate::Module> {
self.shared_lib()
}
}
#[cfg(not(feature = "no_function"))]
impl AsRef<crate::Shared<crate::Module>> for AST {
#[inline(always)]