Skip to content

Commit

Permalink
Merge pull request #47 from JuliaString/ox/generic
Browse files Browse the repository at this point in the history
Handle constructing from AbstractString
  • Loading branch information
oxinabox authored Apr 13, 2021
2 parents ce799ae + 48574ed commit a2ef2a7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
9 changes: 4 additions & 5 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
name = "ShortStrings"
uuid = "63221d1c-8677-4ff0-9126-0ff0817b4975"
authors = ["Dai ZJ <[email protected]>", "ScottPJones <[email protected]>",
"Lyndon White <[email protected]>"]
version = "0.3.6"
authors = ["Dai ZJ <[email protected]>", "ScottPJones <[email protected]>", "Lyndon White <[email protected]>"]
version = "0.3.7"

[deps]
BitIntegers = "c3b6d118-76ef-56ca-8cc7-ebb389d030a1"
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
MurmurHash3 = "b10b62ed-fbae-5ea5-b934-abaf0477b71d"
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"

[compat]
MurmurHash3 = "1.1"
BitIntegers = "0.2"
MurmurHash3 = "1.1"
SortingAlgorithms = "0.3"
julia = "1"

Expand Down
2 changes: 2 additions & 0 deletions src/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ end
val
end

ShortString{T}(s::AbstractString) where T = ShortString{T}(String(s))

function ShortString{T}(s::Union{String,SubString{String}}) where {T}
sz = sizeof(s)
sz === 0 && return ShortString{T}(T(0))
Expand Down
6 changes: 6 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ end

@test_throws ErrorException ShortString("foobar", 3)
@test_throws ErrorException ss"foobar"b3


@test ShortString7(Test.GenericString("abcde")) == "abcde"
@test ShortString7(Test.GenericString("abcde")) isa ShortString7
@test ShortString7(SubString(Test.GenericString("abcde"), 2)) == "bcde"
@test ShortString7(SubString(Test.GenericString("abcde"), 2)) isa ShortString7
end


Expand Down

2 comments on commit a2ef2a7

@oxinabox
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/34208

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.3.7 -m "<description of version>" a2ef2a7bcd9fa1701a3896cbe47fa01e5a5c0773
git push origin v0.3.7

Please sign in to comment.