-
Notifications
You must be signed in to change notification settings - Fork 4
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
Relax Sized bound #2
Comments
Looking at the implementation of this, we either need //! simplified for brevity
/// Doesn't compile T-T
fn pack_stable(ptr: *mut [T], data: usize) -> Ointer<[T]> {
// ------------------------------------------ we drop the metadata (length information)
// vvvvvvvvvv vvvvvvvvvvv--- we don't have the required metadata
(ptr as *mut () as usize | data) as *mut [T]
}
#![feature(ptr_metadata)]
fn pack_ptr_metadata(ptr: *mut [T], data: usize) -> *mut [T] {
// extract metadata
let (ptr, metadata) = ptr.to_raw_parts();
// we can now restore the metadata ------------vvvvvvvv
core::ptr::from_raw_parts(ptr as usize | data, metadata) as *mut [T]
}
#![feature(strict_provenance)]
fn pack_ptr_metadata(ptr: *mut [T], data: usize) -> *mut [T] {
// manipulate the addr directly 😍
ptr.map_addr(|addr| (addr | data))
} As always, nightly is where all the cool stuff lies 😢 |
|
T-T it requires rust-lang/rust#69835 for the debug assertions as Also, we use |
sorry, i've been ignoring github notifications for the most part. in principle it should be fine to support wide pointers, but as you say there's always a catch somewhere. i decided to go with plain pointers while they worked some of the kinks out. the wide pointer support is a bit half-arsed IMO, but hopefully one day they'll fill the gaps. |
No worries, I'm subscribed to basically every relevant thread on this matter so as soon as support is on beta/stable I'll update the issue c: |
Currently there is a sized bound on
T
for all structs, I don't think it is necessary and it prevents me from defining aMaybeBoxed
type based on this crate:This is great for zero copy deserialization where
Cow<'a, T>
is unnecessary because the structure itself does not provide&mut T
or similar access (thusCow<'a, T>
is 24-bytes instead of 16-bytes on 64-buit systems).I specifically want to be able to use
ointers::NonNull<[T]> and ointers::NonNull<str>
c:The text was updated successfully, but these errors were encountered: