0
0
Fork 0
mirror of https://github.com/denoland/rusty_v8.git synced 2024-11-24 15:19:31 -05:00

add from impls for startupdata

This commit is contained in:
crowlkats 2022-05-25 18:54:03 +02:00 committed by Bert Belder
parent fbb081e55f
commit 6f671c05d0
No known key found for this signature in database
GPG key ID: 7A77887B2E2ED461

View file

@ -53,6 +53,26 @@ pub struct StartupData {
raw_size: int, raw_size: int,
} }
impl From<Box<[u8]>> for StartupData {
fn from(slice: Box<[u8]>) -> Self {
let mut data: Vec<u8> = vec![];
data.copy_from_slice(&slice);
StartupData {
data: data.as_ptr() as *const char,
raw_size: data.len() as int,
}
}
}
impl From<&[u8]> for StartupData {
fn from(slice: &[u8]) -> Self {
StartupData {
data: slice.as_ptr() as *const char,
raw_size: slice.len() as int,
}
}
}
impl Deref for StartupData { impl Deref for StartupData {
type Target = [u8]; type Target = [u8];
fn deref(&self) -> &Self::Target { fn deref(&self) -> &Self::Target {