FEAT: Add CapacityError::new

This commit is contained in:
bluss
2017-09-24 17:41:40 +02:00
parent 1a202a904e
commit 9825e58061
3 changed files with 3 additions and 10 deletions
-1
View File
@@ -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
View File
@@ -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
-1
View File
@@ -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;