Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

functor RefValue #26

Merged
merged 3 commits into from
Oct 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Functors"
uuid = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
authors = ["Mike J Innes <[email protected]>"]
version = "0.2.6"
version = "0.2.7"

[compat]
julia = "1"
Expand Down
1 change: 1 addition & 0 deletions src/Functors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ module Functors
export @functor, @flexiblefunctor, fmap, fmapstructure, fcollect

include("functor.jl")
include("base.jl")

end # module
1 change: 1 addition & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@functor Base.RefValue
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're starting a new file, https://github.com/FluxML/Functors.jl/blob/master/src/functor.jl#L10-L12 should be in here as well

8 changes: 8 additions & 0 deletions test/base.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@testset "Base" begin
@testset "RefValue" begin
x = Ref(1)
p, re = Functors.functor(x)
@test p == (x = 1,)
@test re(p) isa Base.RefValue{Int}
end
end
2 changes: 0 additions & 2 deletions test/basics.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using Functors, Test

struct Foo
x
y
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ using Functors, Test
@testset "Functors.jl" begin

include("basics.jl")
include("base.jl")

end