diff --git a/REQUIRE b/REQUIRE index b213ed1..7edcc3b 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ julia 0.6 -Nulls +Missings diff --git a/src/WeakRefStrings.jl b/src/WeakRefStrings.jl index f9d9900..4030a14 100644 --- a/src/WeakRefStrings.jl +++ b/src/WeakRefStrings.jl @@ -3,7 +3,7 @@ module WeakRefStrings export WeakRefString, WeakRefStringArray -using Nulls +using Missings """ A custom "weakref" string type that only points to external string data. @@ -81,24 +81,24 @@ struct WeakRefStringArray{T, N} <: AbstractArray{T, N} end WeakRefStringArray(data::Vector{UInt8}, ::Type{T}, rows::Integer) where {T <: WeakRefString} = WeakRefStringArray(Any[data], zeros(T, rows)) -WeakRefStringArray(data::Vector{UInt8}, ::Type{Union{Null, T}}, rows::Integer) where {T} = WeakRefStringArray(Any[data], Vector{Union{Null, T}}(rows)) -WeakRefStringArray(data::Vector{UInt8}, A::Array{T}) where {T <: Union{WeakRefString, Null}} = WeakRefStringArray(Any[data], A) +WeakRefStringArray(data::Vector{UInt8}, ::Type{Union{Missing, T}}, rows::Integer) where {T} = WeakRefStringArray(Any[data], Vector{Union{Missing, T}}(rows)) +WeakRefStringArray(data::Vector{UInt8}, A::Array{T}) where {T <: Union{WeakRefString, Missing}} = WeakRefStringArray(Any[data], A) wk(w::WeakRefString) = string(w) -wk(::Null) = null +wk(::Missing) = missing Base.size(A::WeakRefStringArray) = size(A.elements) Base.getindex(A::WeakRefStringArray, i::Int) = wk(A.elements[i]) Base.getindex(A::WeakRefStringArray{T, N}, I::Vararg{Int, N}) where {T, N} = wk.(A.elements[I...]) -Base.setindex!(A::WeakRefStringArray{T, N}, v::Null, i::Int) where {T, N} = setindex!(A.elements, v, i) -Base.setindex!(A::WeakRefStringArray{T, N}, v::Null, I::Vararg{Int, N}) where {T, N} = setindex!(A.elements, v, I...) +Base.setindex!(A::WeakRefStringArray{T, N}, v::Missing, i::Int) where {T, N} = setindex!(A.elements, v, i) +Base.setindex!(A::WeakRefStringArray{T, N}, v::Missing, I::Vararg{Int, N}) where {T, N} = setindex!(A.elements, v, I...) Base.setindex!(A::WeakRefStringArray{T, N}, v::WeakRefString, i::Int) where {T, N} = setindex!(A.elements, v, i) Base.setindex!(A::WeakRefStringArray{T, N}, v::WeakRefString, I::Vararg{Int, N}) where {T, N} = setindex!(A.elements, v, I...) Base.setindex!(A::WeakRefStringArray{T, N}, v::String, i::Int) where {T, N} = (push!(A.data, Vector{UInt8}(v)); setindex!(A.elements, v, i)) Base.setindex!(A::WeakRefStringArray{T, N}, v::String, I::Vararg{Int, N}) where {T, N} = (push!(A.data, Vector{UInt8}(v)); setindex!(A.elements, v, I...)) Base.resize!(A::WeakRefStringArray, i) = resize!(A.elements, i) -Base.push!(a::WeakRefStringArray{T, 1}, v::Null) where {T} = (push!(a.elements, v); a) +Base.push!(a::WeakRefStringArray{T, 1}, v::Missing) where {T} = (push!(a.elements, v); a) Base.push!(a::WeakRefStringArray{T, 1}, v::WeakRefString) where {T} = (push!(a.elements, v); a) function Base.push!(A::WeakRefStringArray{T, 1}, v::String) where T push!(A.data, Vector{UInt8}(v)) diff --git a/test/runtests.jl b/test/runtests.jl index 5c9cb4c..52caa04 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,4 +1,4 @@ -using WeakRefStrings, Base.Test, Nulls +using WeakRefStrings, Base.Test, Missings @testset "WeakRefString{UInt8}" begin data = Vector{UInt8}("hey there sailor") @@ -73,13 +73,13 @@ end append!(A, B) @test size(A) == (17,) - D = WeakRefStringArray(UInt8[], Union{Null, WeakRefString{UInt8}}, 0) + D = WeakRefStringArray(UInt8[], Union{Missing, WeakRefString{UInt8}}, 0) push!(D, "hey") push!(D, str) - push!(D, null) + push!(D, missing) @test length(D) == 3 @test D[2] == str - @test D[3] === null - D[2] = null - @test D[2] === null + @test D[3] === missing + D[2] = missing + @test D[2] === missing end