Comments (3)
I'm afraid that such a change would be a very big one, and cause unacceptable levels of increased danger of things going wrong. Even just as an opt-in feature, I think it's too much.
What's mostly actually being required is "not Drop", because Pod lets you make a value from nowhere so the type better not have any Drop code. Technically since it's an unsafe trait that Copy requirement could just be torn out and additional unsafe requirements could be written into the docs. If it had been like that from the start maybe that would be fine, but at this point I wouldn't feel comfortable making such a significant change.
This sounds like something you should solve within your crate by just carefully looking at all your function signatures and watching that they accept references as often as possible. As long as it's always a reference when passed between functions things should be fine.
from bytemuck.
This sounds like something you should solve within your crate by just carefully looking at all your function signatures and watching that they accept references as often as possible. As long as it's always a reference when passed between functions things should be fine.
What? We are working in Rust for a reason. Actually I just need the one-way transformation. I am not sure which checks are required to be safe, but I don't have so many structs to transform and they are all pure multiples of 32 bit fields. I will write those 2 lines myself from scratch. I feel better this way than to miss a &-reference in a function call and loose performance due to unnecessary allocations.
Thanks anyway!
Edit: fixed the quote
from bytemuck.
I hope you're aware that passing by reference can also give performance losses depending on the situation.
But yes, it should be simple enough to write an as_u32_slice
function on your intended types.
from bytemuck.
Related Issues (20)
- `TransparentWrapper` derive unsoundness HOT 12
- cast_slice on a memory-mapped file fails on Windows but succeeds on Linux HOT 4
- `#[repr(transparent)]` wrapper around `[u8]` DST HOT 1
- Suboptimal assembly for Contiguous derive HOT 9
- Should `pod_collect_to_vec()` input type require `AnyBitPattern`? HOT 8
- Derive gives `clippy::extra_unused_type_parameters` warnings HOT 4
- Mark try_from_bytes function as unsafe HOT 4
- consider updating to syn 2.0.0 HOT 2
- use #[inline(always)] instead of #[inline] HOT 3
- Consider adding `doc(hidden)` to impl details? HOT 1
- Allow deriving `Zeroable` with explicitly provided bounds HOT 11
- Allow deriving `Pod` for structs where generics are used only as `PhantomData` HOT 2
- Derive macro doesn't work when exported HOT 1
- Fails to compile with rustc 1.72.0-nightly (fe7454bf4 2023-06-19) HOT 8
- Raw pointer cast functions HOT 4
- Cannot use derive macros when reexporting bytemuck from library HOT 2
- Crate makes assumptions about bool values HOT 5
- Safe `offset_of` for packed structs using `addr_of`? HOT 9
- `ASSERT_SIZE_MULTIPLE_OF` when casting `&[u8]` to `&[[u8; 16]]` HOT 1
- Crate documentation is misleading, implies `Pod` required for all functions. HOT 3
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 bytemuck.