-
Notifications
You must be signed in to change notification settings - Fork 57
Add support for vec, slice & array in create_property_blob #219
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
Add support for vec, slice & array in create_property_blob #219
Conversation
|
(Typo in the title Perhaps if fn test<T: ?Sized>(x: &T) {
dbg!(std::mem::size_of_val(x));
// dbg!(std::mem::size_of::<T>());
}
fn main() {
let x = vec![1u32];
dbg!(test(x.as_slice())); // 4, byte-size of the slice
dbg!(test(&x)); // 24, size of the `Vec<..>` structure
} |
|
Done 👍 agreed! Made the requested changes @MarijnS95 |
|
Hi @Drakulix, can you review this PR ?? We need this updated crate :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
|
Perhaps this PR should have been squashed before it was rebase-merged (or it should have been squash-merged). Note that the function as written is still unsound, because it crates a safe |
Yes, that was an oversight.
Right, we should probably add the same trait requirement or directly use |
|
Unfortunately |
|
And like I mentioned in #219 (comment), the title is misleading because passing a |
I still think supporting slices is a good idea, I am not sure how to add trait bounds that would enforce a deref for At least we should add more documentation on this issue before pushing a new release, but I am open for better ideas. |
|
Those |
To support vectors and slices in addition to arrays in the create_property_blob function, you can use generics and trait bounds to handle different types of data.
This modification ensures that the function is flexible and can handle different types of contiguous data structures.