Skip to content

Commit

Permalink
Box SystemTime in EncodeError
Browse files Browse the repository at this point in the history
  • Loading branch information
maciejhirsz committed Jun 15, 2022
1 parent 6ecb853 commit fd9c82e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub enum EncodeError {
/// The error that was thrown by the SystemTime
inner: std::time::SystemTimeError,
/// The SystemTime that caused the error
time: std::time::SystemTime,
time: std::boxed::Box<std::time::SystemTime>,
},

#[cfg(feature = "serde")]
Expand Down
2 changes: 1 addition & 1 deletion src/features/impl_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl Encode for SystemTime {
let duration = self.duration_since(SystemTime::UNIX_EPOCH).map_err(|e| {
EncodeError::InvalidSystemTime {
inner: e,
time: *self,
time: std::boxed::Box::new(*self),
}
})?;
duration.encode(encoder)
Expand Down
5 changes: 1 addition & 4 deletions tests/error_size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@ fn decode_error_size() {

#[test]
fn encode_error_size() {
#[cfg(feature = "std")]
assert_eq!(std::mem::size_of::<bincode::error::EncodeError>(), 40);

#[cfg(all(feature = "alloc", not(feature = "std")))]
#[cfg(any(feature = "std", feature = "alloc"))]
assert_eq!(std::mem::size_of::<bincode::error::EncodeError>(), 32);

#[cfg(not(any(feature = "std", feature = "alloc")))]
Expand Down

0 comments on commit fd9c82e

Please sign in to comment.