From 5f2262214d7230bdd8c2e6d5f1a4b336cd77d932 Mon Sep 17 00:00:00 2001 From: Stephen Chung Date: Sun, 14 Aug 2022 18:16:35 +0800 Subject: [PATCH] Add docs. --- src/ast/expr.rs | 2 ++ src/types/dynamic.rs | 3 +++ 2 files changed, 5 insertions(+) diff --git a/src/ast/expr.rs b/src/ast/expr.rs index e5208eee..e86531d0 100644 --- a/src/ast/expr.rs +++ b/src/ast/expr.rs @@ -362,6 +362,8 @@ pub enum Expr { /// /// Used to hold complex constants such as [`Array`][crate::Array] or [`Map`][crate::Map] for quick cloning. /// Primitive data types should use the appropriate variants to avoid an allocation. + /// + /// The [`Dynamic`] value is boxed in order to avoid bloating the size of [`Expr`]. DynamicConstant(Box, Position), /// Boolean constant. BoolConstant(bool, Position), diff --git a/src/types/dynamic.rs b/src/types/dynamic.rs index f95a2275..1a37cd16 100644 --- a/src/types/dynamic.rs +++ b/src/types/dynamic.rs @@ -186,6 +186,9 @@ pub enum Union { TimeStamp(Box, Tag, AccessMode), /// Any type as a trait object. + /// + /// An extra level of redirection is used in order to avoid bloating the size of [`Dynamic`] + /// because `Box` is a fat pointer. Variant(Box>, Tag, AccessMode), /// A _shared_ value of any type.