Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upTracking issue for std::slice::bytes #27740
Comments
alexcrichton
added
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
|
I tend to copy that module to every single project I write in Rust (for instance, https://github.com/cesarb/blake2-rfc/blob/master/src/bytes.rs), as a safe and easy-use implementation of They do optimize down to either direct moves/writes through vector registers or to straight calls to memset/memcpy, so I don't see how it being in the standard library would guarantee any optimization over a local copy of the exact same code. I believe this functionality should be exposed, as it's very useful when dealing with byte ( The question is how to expose it. The current way works well, but looks strange.
This design inconsistency becomes very obvious when you want to use both:
IMHO, either both should be standalone functions, or both should be in a trait:
Another question is where to expose it. I don't see much point on that single-use module, so either directly on |
This comment has been minimized.
This comment has been minimized.
|
If you want, I could write a RFC for the trait alternative (without memmove). |
Ms2ger
referenced this issue
Aug 16, 2015
Open
Tracking: Unstable Rust feature gates used by Servo #5286
This comment has been minimized.
This comment has been minimized.
|
Nominating for discussion for 1.6. Discuss post. cc @briansmith |
aturon
added
the
I-nominated
label
Nov 4, 2015
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Nov 5, 2015
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage today and the decision was to deprecate |
This comment has been minimized.
This comment has been minimized.
|
Is there a recommended, stable replacement for this functionality? |
This comment has been minimized.
This comment has been minimized.
|
Yes, basically just using iterators and loops. |
This comment has been minimized.
This comment has been minimized.
|
That’s, hum, unfortunate. Writing a trivial loop like this is annoying enough that it’s tempting (IMO) to use I think this functionality belongs in the standard library, whatever its API looks like. |
This comment has been minimized.
This comment has been minimized.
|
It's likely this can either be replaced via |
This comment has been minimized.
This comment has been minimized.
|
These functions can also exist in a tiny utility crate (where it would make sense to generalise to any |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bluss Ah, interesting. The deprecation message should mention that. |
alexcrichton commentedAug 12, 2015
This is a tracking issue for the unstable
slice_bytesfeature in the standard library. This module has some various helper methods for dealing with blocks of bytes in an efficient fashion, but they seem particularly one-off and not necessarily fitting in with the rest of the design of the standard library.Some drawbacks are:
MutableByteVectoris used to give slices theset_memorymethod.copy_memoryfunction is used to provide essentially safe bindings tomemcpyBoth of these can be implemented in stable Rust otherwise and get optimized down to the same implementation, but it's often useful to call them directly to guarantee the optimization will happen. Needs a decision to whether this functionality should be exposed, where it should be exposed, and how.