Skip to content

Commit

Permalink
added small docstring to Leaf
Browse files Browse the repository at this point in the history
  • Loading branch information
torfjelde committed Sep 1, 2023
1 parent 49bb2c5 commit b96fa22
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b96fa22

Please sign in to comment.