ShortStrings.jl icon indicating copy to clipboard operation
ShortStrings.jl copied to clipboard

Construct from MVector

Open jariji opened this issue 3 years ago • 2 comments

I have a StaticArrays.MVector and I want to make ShortString. Should this be possible?

julia> using StaticArrays, ShortStrings; ShortString(@MVector UInt8[1,2,3,4])
Error showing value of type ShortString{MVector{4, UInt8}}:
ERROR: DimensionMismatch("No precise constructor for MVector{4, UInt8} found. Length of input was 1.")

jariji avatar Mar 29 '22 09:03 jariji

You need to broadcast over the vector.

julia> ShortString.(@MVector UInt8[1,2,3,4])
4-element MVector{4, ShortString{UInt8}} with indices SOneTo(4):
 ""
 ""
 ""
 ""

tbeason avatar Mar 30 '22 19:03 tbeason

I want to make one ShortString out of the MVector, just like I can make one String out of the MVector.

julia> String(@MVector UInt8[97,98,99])
"abc"

julia> ShortString(@MVector UInt8[97,98,99])
Error showing value of type ShortString{MVector{3, UInt8}}:
ERROR: DimensionMismatch("No precise constructor for MVector{3, UInt8} found. Length of input was 1.")

jariji avatar Mar 30 '22 19:03 jariji