Comments (10)
Exactly. I'd submit a PR, but I'm currently low on time. I expect to have more time after ~2 weeks.
from byteorder.
This is weird, I completely forgot about this. I do remember trying to add unsafe
but something stopped me and then I didn't continue for some reason. Can't remember anything more. I guess it's a good thing because MaybeUninit
was introduced since then and it doesn't make sense to guarantee anything about uninitialized &mut [u8]
as that's UB already.
No change is actually required because performant writing can be done safely already: https://play.rust-lang.org/?version=stable&mode=release&edition=2018&gist=26babbb49afda7644f61f4e7ffe1ad2c
TL;DR is that writing to a safe, 0-init array first and then copying it into uninit slice gets optimized just fine.
It could be nice to guarantee that unsafe code can rely on values being written as expected but I personally wouldn't consider unsafe code being broken if it relies on it implicitly as that's a reasonable assumption.
Maybe a more appropriate label would be magically-fixed-itself
instead of wontfix
. 😆
from byteorder.
This seems reasonable to me. I can't imagine any circumstances under which the write
methods would actually want to read from the buffer. Can you?
from byteorder.
I can't. Would it be breaking change to make the trait unsafe
? If the only implementors are LittleEndian
and BigEndian
, then it should be fine...
from byteorder.
Ping?
from byteorder.
I don't think it would be a breaking change.
Why does the standard io::Read
trait not make this guarantee?
from byteorder.
There's a PR addressing this.
from byteorder.
I see. So it seems like the preferred solution is to make the trait unsafe
, but we couldn't do that for std::io::Read
. However, I believe we can here since the trait is sealed.
from byteorder.
Sorry, I forgot about this completely. I'll look at it today (not sooner than 9 hours from now).
from byteorder.
I think that if you're already dealing with unsafe code and uninitialized buffers, then it probably doesn't make sense to use byteorder's safe APIs, since they impose a cost.
from byteorder.
Related Issues (20)
- Support async analogues of Read and Write extensions HOT 2
- Add `read_u40` HOT 1
- Using byteorder with type definitions HOT 1
- upgrade quickcheck to 1.0
- panic in try from slice HOT 4
- Changelog is not up to date
- Document MSRV HOT 1
- Rust is failing to find type definitions or enumerations HOT 2
- Consider supporting outdated Rust versions to make bincode happy HOT 1
- Add impl of `ReadBytesExt` and `WriteBytesExt` for `core2::io::Write` HOT 7
- Implement `read_usize` HOT 5
- Transparently support reading into arrays of types that are byte-compatible with integers HOT 1
- Endianness-managing Read/Write wrapper? HOT 2
- add ReadFrom and WriteTo traits with a derive macro HOT 1
- Any difference to Rust official functions? HOT 1
- Unsound assumption about the alignment of u32 and f32
- write_i64 does not write to the buffer HOT 2
- [Bug] Some unknown error caused by byteorder 1.5.0 HOT 1
- Expose `#[forbid(unsafe_code)]` subset HOT 3
- write_int never panics on out of range input
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from byteorder.