pub struct InlineError<const N: usize = 16> { /* private fields */ }Expand description
An implementation of Box<dyn std::error::Error> that stores the error payload inline,
avoiding dynamic memory allocation. This has several practical drawbacks:
- The size of the error payload must be at most
Nbytes. - The alignment of the error payload must be at most 8 bytes.
Both of these contraints are verified using post-monomorphization errors.
§Example
use diskann_quantization::error::InlineError;
let base_error = u32::try_from(u64::MAX).unwrap_err();
let mut error = InlineError::<8>::new(base_error);
assert_eq!(error.to_string(), base_error.to_string());
// Change the dynamic type of the contained error.
error = InlineError::new(Box::new(base_error));
assert_eq!(error.to_string(), base_error.to_string());Implementations§
Source§impl<const N: usize> InlineError<N>
impl<const N: usize> InlineError<N>
Trait Implementations§
Source§impl<const N: usize> Debug for InlineError<N>
impl<const N: usize> Debug for InlineError<N>
Source§impl<const N: usize> Display for InlineError<N>
impl<const N: usize> Display for InlineError<N>
Source§impl<const N: usize> Drop for InlineError<N>
impl<const N: usize> Drop for InlineError<N>
Source§impl<const N: usize> Error for InlineError<N>
impl<const N: usize> Error for InlineError<N>
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
impl<const N: usize> Send for InlineError<N>
impl<const N: usize> Sync for InlineError<N>
Auto Trait Implementations§
impl<const N: usize = 16> !Freeze for InlineError<N>
impl<const N: usize = 16> !RefUnwindSafe for InlineError<N>
impl<const N: usize> Unpin for InlineError<N>
impl<const N: usize> UnsafeUnpin for InlineError<N>
impl<const N: usize> UnwindSafe for InlineError<N>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more