-
Notifications
You must be signed in to change notification settings - Fork 192
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
Added conversion for Vec<u8> #699
Changes from 2 commits
ee1bbf2
1a8e8d4
36f7d67
af5824b
b68cb30
5012493
a7e4264
a599f24
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,27 @@ | |
|
||
//! Adapters for alternative string formats. | ||
|
||
use crate::{ | ||
std::{borrow::Borrow, fmt, ptr, str}, | ||
Uuid, Variant, | ||
}; | ||
use alloc::vec::Vec; | ||
use crate::{Bytes, std::{borrow::Borrow, fmt, ptr, str}, Uuid, Variant}; | ||
|
||
impl From<Uuid> for Vec<u8>{ | ||
fn from(value: Uuid) -> Self { | ||
value.as_bytes().to_vec() | ||
} | ||
} | ||
|
||
impl From<Vec<u8>> for Uuid{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we should add this side of the conversion. Converting slices into |
||
fn from(value: Vec<u8>) -> Self { | ||
let mut arr: [u8; 16] = [0;16]; | ||
|
||
value.into_iter() | ||
.take(16) | ||
.enumerate() | ||
.for_each(|(i, v)| arr[i] = v); | ||
|
||
Uuid(arr) | ||
} | ||
} | ||
|
||
impl std::fmt::Debug for Uuid { | ||
#[inline] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -272,6 +272,7 @@ mod macros; | |
#[doc(hidden)] | ||
#[cfg(feature = "macro-diagnostics")] | ||
pub extern crate uuid_macro_internal; | ||
extern crate alloc; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This will also need to be conditionally compiled. |
||
|
||
#[doc(hidden)] | ||
pub mod __macro_support { | ||
|
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.
This will need to be conditionally compiled, with a
#[cfg(feature = “std”])
.