Skip to content

Commit 19788ea

Browse files
mcabbottToucheSir
andauthored
@functor Returns (#71)
* functor Returns * Update src/base.jl Co-authored-by: Brian Chen <[email protected]> * Update test/base.jl --------- Co-authored-by: Brian Chen <[email protected]>
1 parent fa601bb commit 19788ea

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Functors"
22
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
33
authors = ["Mike J Innes <[email protected]>"]
4-
version = "0.4.5"
4+
version = "0.4.6"
55

66
[deps]
77
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"

src/base.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
@functor Base.Fix2
1111
@functor Base.Broadcast.BroadcastFunction
1212

13+
@static if VERSION >= v"1.7"
14+
@functor Base.Returns
15+
end
16+
1317
###
1418
### Array wrappers
1519
###

test/base.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ end
5050
@test fmap(x -> x + 10, bf) == Base.Broadcast.BroadcastFunction(Bar(13.3))
5151
end
5252

53+
VERSION >= v"1.7" && @testset "Returns" begin
54+
ret = Returns([0, pi, 2pi])
55+
@test Functors.functor(ret)[1] == (value = [0, pi, 2pi],)
56+
@test Functors.functor(ret)[2]((value = 1:3,)) === Returns(1:3)
57+
end
58+
5359
@testset "LinearAlgebra containers" begin
5460
@test fmapstructure(identity, [1,2,3]') == (parent = [1, 2, 3],)
5561
@test fmapstructure(identity, transpose([1,2,3])) == (parent = [1, 2, 3],)

0 commit comments

Comments
 (0)