Skip to content

Commit

Permalink
add copyto! and unsafe_copyto!
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrikekre committed Jan 9, 2018
1 parent 50c6b36 commit 3f296bf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,8 @@ Currently, the `@compat` macro supports the following syntaxes:

* `unshift!` and `shift!` are now `pushfirst!` and `popfirst!` ([#25100]).

* `copy!` and `unsafe_copy!` are now `copyto!` and `unsafe_copyto!` ([#24808]).

* `ipermute!` is now `invpermute!` ([#25168]).

## New macros
Expand Down Expand Up @@ -435,4 +437,4 @@ includes this fix. Find the minimum version from there.
[#25162]: https://github.com/JuliaLang/julia/issues/25162
[#25165]: https://github.com/JuliaLang/julia/issues/25165
[#25168]: https://github.com/JuliaLang/julia/issues/25168
[#25113]: https://github.com/JuliaLang/julia/issues/25113
[#25113]: https://github.com/JuliaLang/julia/issues/25113
7 changes: 7 additions & 0 deletions src/Compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1070,6 +1070,13 @@ end
replace(s, first(pat_rep), last(pat_rep), count)
end

# 0.7.0-DEV.3057
@static if !isdefined(Base, :copyto!)
const copyto! = Base.copy!
const unsafe_copyto! = Base.unsafe_copy!
export copyto!, unsafe_copyto!
end

@static if VERSION < v"0.7.0-DEV.3025"
import Base: convert, ndims, getindex, size, length, eltype,
start, next, done, first, last
Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,14 @@ let coolvec = [1,2,3]
@test popfirst!(coolvec) == 0
end

# 0.7.0-DEV.3057
let A = [0, 0, 0], B = [1, 2, 3]
@test copyto!(A, B) === A == B
end
let A = [0, 0, 0], B = [1, 2, 3]
@test unsafe_copyto!(A, 2, B, 1, 1) === A == [0, 1, 0]
end

# 0.7.0-DEV.3173
@test invpermute!(permute!([1, 2], 2:-1:1), 2:-1:1) == [1, 2]

Expand Down

0 comments on commit 3f296bf

Please sign in to comment.