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