-
-
Notifications
You must be signed in to change notification settings - Fork 146
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
improve byteorder docs for ReadBytesExt/WriteBytesExt #130
Comments
I needed to say |
@rivertam I think it's a little weird to expect this in the |
Fair enough. The reason I say this is really that I'd never heard of |
You might be able to get away with the |
@BurntSushi when I try with a vec I get:
and when I try with a
I would definitely rather use a slice or a smallvec because heap allocations just seem very wasteful here. |
@rivertam Basically, all you need is something that impls
So in your compilation errors, you appear to be using an array, which usually coerces to a slice, but won't in the presence of generics. So if Here's an example that uses a plain And here's an example that uses a plain With all that said, if you don't want heap allocation, then it might make sense to not even bother with the The last example is probably how I'd write the code in your original comment myself. I would only use the I agree that all of this should probably make it in the byteorder docs somehow, so I'll re-purpose this ticket for just that. :-) |
@BurntSushi Oh wow thank you so much. You da bomb |
I believe I'm doing this correctly. I'm trying to create an f64 from 4 u16s.
My
println
outputsCursor { inner: [0, 0, 1, 0, 2, 0, 3, 0], pos: 8 }
, but theread_f64
line panics with:Am I doing something wrong? 8 x 8 = 64, so I believe the cursor has the correct number of bytes in it. I see no reason why this would be erroring in this way.
The text was updated successfully, but these errors were encountered: