3 ms·
So it’s basically like a Span in C# if I understood correctly?
by tigershark 8y ago
So it’s basically like a Span in C# if I understood correctly?
- steveklabnik 8y agoI am not familiar with the in-memory representation of Slice, but conceptually at least, yes. We call &str a "string slice" and &[T] more generally a "slice". EDIT: apparently you just edited from Slice to Span, reading https://msdn.microsoft.com/en-us/magazine/mt814808.aspx https://msdn.microsoft.com/en-us/magazine/mt814808.aspx > First, Span<T> is a value type containing a ref and a length, defined approximately as follows: Yep, exactly the same as Span<T> then.
- tigershark 8y agoSorry, I wrote Slice instead of Span in the original comment... Slice is the method that returns a Span that is the equivalent of this rust concept as far as I can tell. At some point in the future I’ll need to delve in rust, it’s quite fascinating, but sadly I don’t have much time nowadays :(
- steveklabnik 8y agoIt's all good, on both counts! We'll still be around when you find the time :)
- GrayShade 8y agoIt's actually like a ref Span argument, if my understanding of it is correct. &[T] is like Span<T>, while a &mut &[T] is like a reference to a Span<T>.