Skip to content
Merged
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
10 changes: 6 additions & 4 deletions src/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,12 @@ operate(::typeof(convert), ::Type{T}, x::T) where {T} = copy_if_mutable(x)

operate(::Union{typeof(+),typeof(*)}, x) = copy_if_mutable(x)

# We only give the type to `zero` and `one` to be sure that modifying the
# returned object cannot alter `x`.
operate(::typeof(zero), x) = zero(typeof(x))
operate(::typeof(one), x) = one(typeof(x))
# We could only give `typeof(x)` to `zero` and `one` to be sure that modifying the
# returned object cannot alter `x` but for some objects, `one` and `zero` depends
# on some values of the fields (e.g. square matrices), elements of the cyclic group
# of order `n` (`n` is one of the field).
operate(::typeof(zero), x) = zero(x)
operate(::typeof(one), x) = one(x)

# Define Traits

Expand Down