mirror of
https://github.com/Lokathor/bytemuck.git
synced 2024-11-25 00:02:22 +00:00
This commit is contained in:
parent
2d41741f40
commit
1be7a90f16
@ -15,7 +15,9 @@ exclude = ["/scripts/*", "/.travis.yml", "/appveyor.yml", "/bors.toml", "/pedant
|
||||
all-features = true
|
||||
|
||||
[features]
|
||||
# Note: Yeah these names are non-standard, we'll fix it in v2 some day maybe
|
||||
extern_crate_alloc = []
|
||||
extern_crate_std = ["extern_crate_alloc"]
|
||||
|
||||
[badges]
|
||||
appveyor = { repository = "Lokathor/bytemuck" }
|
||||
|
@ -8,6 +8,8 @@
|
||||
* The `offset_of!` macro now supports a 2-arg version. For types that impl
|
||||
Default, it'll just make an instance using `default` and then call over to the
|
||||
3-arg version.
|
||||
* The `PodCastError` type now supports `Hash` and `Display`. Also if you enable
|
||||
the `extern_crate_std` feature then it will support `std::error::Error`.
|
||||
|
||||
## 1.2.0
|
||||
|
||||
|
12
src/lib.rs
12
src/lib.rs
@ -56,6 +56,9 @@ macro_rules! impl_unsafe_marker_for_array {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "extern_crate_std")]
|
||||
extern crate std;
|
||||
|
||||
#[cfg(feature = "extern_crate_alloc")]
|
||||
extern crate alloc;
|
||||
#[cfg(feature = "extern_crate_alloc")]
|
||||
@ -187,7 +190,7 @@ pub fn try_from_bytes_mut<T: Pod>(
|
||||
}
|
||||
|
||||
/// The things that can go wrong when casting between [`Pod`] data forms.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub enum PodCastError {
|
||||
/// You tried to cast a slice to an element type with a higher alignment
|
||||
/// requirement but the slice wasn't aligned.
|
||||
@ -204,6 +207,13 @@ pub enum PodCastError {
|
||||
/// were not so now you're sad.
|
||||
AlignmentMismatch,
|
||||
}
|
||||
impl core::fmt::Display for PodCastError {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
write!(f, "{:?}", self)
|
||||
}
|
||||
}
|
||||
#[cfg(feature = "extern_crate_std")]
|
||||
impl std::error::Error for PodCastError {}
|
||||
|
||||
/// Cast `T` into `U`
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user