Description
With String(::Vector{UInt8})
, we could always resize!
the bytes before truncating and returning the String
. With Memory{UInt8}
, however, we obviously can't resize!
. jl_genericmemory_to_string
, however, does already take a length argument for how many bytes to use in the Memory
to create the string, even if it still truncates the entire Memory to 0 bytes.
So the request here is that we provide something like String(m::Memory{UInt8}, len=length(m))
, even though that feels a little weird to have 2 arguments to the String
constructor like that. I thought of maybe using unsafe_string(m, len)
for this, but it's not really unsafe and the current unsafe_ methods only take pointers.
Open to other suggestions here. I'm certainly not an expert in all the new memory machinery, so maybe I'm missing something more obvious here where it's trivial (and part of the public API) to easily get a "view" of a memory for a given length.