FEAT: Add CapacityError::new
This commit is contained in:
@@ -12,7 +12,6 @@ use std::slice;
|
|||||||
use array::{Array, ArrayExt};
|
use array::{Array, ArrayExt};
|
||||||
use array::Index;
|
use array::Index;
|
||||||
use CapacityError;
|
use CapacityError;
|
||||||
use errors::PubCrateNew;
|
|
||||||
use odds::char::encode_utf8;
|
use odds::char::encode_utf8;
|
||||||
|
|
||||||
#[cfg(feature="serde-1")]
|
#[cfg(feature="serde-1")]
|
||||||
|
|||||||
+3
-8
@@ -10,19 +10,14 @@ pub struct CapacityError<T = ()> {
|
|||||||
element: T,
|
element: T,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PubCrateNew<T> {
|
impl<T> CapacityError<T> {
|
||||||
fn new(elt: T) -> Self;
|
/// Create a new `CapacityError` from `element`.
|
||||||
}
|
pub fn new(element: T) -> CapacityError<T> {
|
||||||
|
|
||||||
impl<T> PubCrateNew<T> for CapacityError<T> {
|
|
||||||
fn new(element: T) -> CapacityError<T> {
|
|
||||||
CapacityError {
|
CapacityError {
|
||||||
element: element,
|
element: element,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> CapacityError<T> {
|
|
||||||
/// Extract the overflowing element
|
/// Extract the overflowing element
|
||||||
pub fn element(self) -> T {
|
pub fn element(self) -> T {
|
||||||
self.element
|
self.element
|
||||||
|
|||||||
@@ -69,7 +69,6 @@ pub use array::Array;
|
|||||||
pub use range::RangeArgument;
|
pub use range::RangeArgument;
|
||||||
use array::Index;
|
use array::Index;
|
||||||
pub use array_string::ArrayString;
|
pub use array_string::ArrayString;
|
||||||
use errors::PubCrateNew;
|
|
||||||
pub use errors::CapacityError;
|
pub use errors::CapacityError;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user