Add code comments.

This commit is contained in:
Stephen Chung
2020-03-18 10:36:50 +08:00
parent 777f66ff3c
commit ca20faf170
4 changed files with 385 additions and 152 deletions

View File

@@ -1,7 +1,7 @@
//! Helper module which defines the `Any` trait to to allow dynamic value handling.
use crate::stdlib::{
any::{self, type_name, TypeId},
any::{type_name, Any as StdAny, TypeId},
boxed::Box,
fmt,
};
@@ -13,7 +13,7 @@ pub type Variant = dyn Any;
pub type Dynamic = Box<Variant>;
/// A trait covering any type.
pub trait Any: any::Any {
pub trait Any: StdAny {
/// Get the `TypeId` of this type.
fn type_id(&self) -> TypeId;
@@ -23,12 +23,12 @@ pub trait Any: any::Any {
/// Convert into `Dynamic`.
fn into_dynamic(&self) -> Dynamic;
/// This type may only be implemented by `rhai`.
/// This trait may only be implemented by `rhai`.
#[doc(hidden)]
fn _closed(&self) -> _Private;
}
impl<T: Clone + any::Any + ?Sized> Any for T {
impl<T: Clone + StdAny + ?Sized> Any for T {
fn type_id(&self) -> TypeId {
TypeId::of::<T>()
}
@@ -91,7 +91,7 @@ pub trait AnyExt: Sized {
/// Get a copy of a `Dynamic` value as a specific type.
fn downcast<T: Any + Clone>(self) -> Result<Box<T>, Self>;
/// This type may only be implemented by `rhai`.
/// This trait may only be implemented by `rhai`.
#[doc(hidden)]
fn _closed(&self) -> _Private;
}