Refine docs and API.

This commit is contained in:
Stephen Chung
2020-07-06 13:01:57 +08:00
parent d9fe6a1980
commit 3e45d5d9a5
12 changed files with 51 additions and 37 deletions

View File

@@ -66,14 +66,14 @@ impl AST {
/// Get the statements.
#[cfg(not(feature = "internals"))]
pub(crate) fn statements(&self) -> &Vec<Stmt> {
pub(crate) fn statements(&self) -> &[Stmt] {
&self.0
}
/// Get the statements.
#[cfg(feature = "internals")]
#[deprecated(note = "this method is volatile and may change")]
pub fn statements(&self) -> &Vec<Stmt> {
pub fn statements(&self) -> &[Stmt] {
&self.0
}
@@ -298,9 +298,15 @@ impl Add<Self> for &AST {
}
}
impl<'a> From<&'a AST> for &'a Module {
fn from(ast: &'a AST) -> Self {
ast.lib()
impl AsRef<[Stmt]> for AST {
fn as_ref(&self) -> &[Stmt] {
self.statements()
}
}
impl AsRef<Module> for AST {
fn as_ref(&self) -> &Module {
self.lib()
}
}