-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
SubString serialization #24266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It would make sense in general to provide a method to convert a |
This could work, but then In general
If in the future someone introduces a new type of string then I would leave it for then to define an efficient serialization method if it would be required. |
Ah, right. It would be nice to provide automatically an efficient serialization method for custom |
Method
serialize(s::AbstractSerializer, ss::SubString{T})
seems to lead to an infinite loop of calls in withTest.GenericString
. I have fixedTest.GenericString
to work around this problem in #24255.However, in general other
<:AbstractString
types might lead to a similar problem.The intention of the method seems to be guaranteed to be achieved only for
String
as in general we do not know whatconvert(T,ss)
will do (GenericString
was wrappingSubString
instead of performing trimming).I can see the following solution:
serialize(s::AbstractSerializer, ss::SubString{String})
which is probably the typical use case and should work as intended;Other natural methods like:
convert(T,ss)
toss.string[start(ss.string)+offset:endof(ss.string)+offset]
, but this touches internal implementation ofSubString
so I am not sure if this is desired;convert(T,Substring{T}) where {T<:AbstractString} = ss.string[start(ss.string)+offset:endof(ss.string)+offset]
in strings/types.jl.will not give benefit as in general
getindex
forAbstractString
usesSubString
to make slices.The text was updated successfully, but these errors were encountered: