Skip to content

Commit

Permalink
Update src/base.jl
Browse files Browse the repository at this point in the history
Co-authored-by: Tim Besard <[email protected]>
  • Loading branch information
charleskawczynski and maleadt authored Mar 5, 2024
1 parent 73d96dd commit 94f809a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/base.jl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# predefined adaptors for working with types from the Julia standard library

_radapt_structure(to, xs::Tuple) =
(adapt(to, first(xs)), _radapt_structure(to, Base.tail(xs))...)
_radapt_structure(to, xs::Tuple{}) = ()
_radapt_structure(to, xs::Tuple{<:Any}) =
(adapt(to, first(xs)), )
# Use recursion on tuples to avoid inference bail-out in `map`
adapt_structure(to, xs::Tuple) = _radapt_structure(to, xs)
#adapt_structure(to, xs::Union{Tuple,NamedTuple}) = map(adapt(to), xs)
adapt_structure(to, xs::NamedTuple) = map(x->adapt(to,x), xs)
adapt_structure(to, xs::Tuple) = _adapt_tuple_structure(to, xs)
_adapt_tuple_structure(to, xs::Tuple) =
(adapt(to, first(xs)), _adapt_tuple_structure(to, Base.tail(xs))...)
_adapt_tuple_structure(to, xs::Tuple{}) = ()
_adapt_tuple_structure(to, xs::Tuple{<:Any}) = (adapt(to, first(xs)), )


## Closures
Expand Down

0 comments on commit 94f809a

Please sign in to comment.