From b96fa2274a84d2bb5b98ad083b5d01c0414aa47a Mon Sep 17 00:00:00 2001 From: Tor Erlend Fjelde Date: Fri, 1 Sep 2023 11:25:58 +0100 Subject: [PATCH] added small docstring to Leaf --- src/utils.jl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/utils.jl b/src/utils.jl index 39899607e..951989a45 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -932,8 +932,16 @@ function varname_and_value_leaves(vn::VarName, x) return Iterators.map(value, Iterators.flatten(varname_and_value_leaves_inner(vn, x))) end -# Simple struct used to represent a varname-value pair even if we use -# something like `Iterators.flatten`. + +""" + Leaf{T} + +A container that represents the leaf of a nested structure, implementing +`iterate` to return itself. + +This is particularly useful in conjunction with `Iterators.flatten` to +prevent flattening of nested structures. +""" struct Leaf{T} value::T end