From 9825e5806181c1235e866195f6f32a07f5187ce6 Mon Sep 17 00:00:00 2001 From: bluss Date: Sun, 24 Sep 2017 17:41:40 +0200 Subject: [PATCH] FEAT: Add CapacityError::new --- src/array_string.rs | 1 - src/errors.rs | 11 +++-------- src/lib.rs | 1 - 3 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/array_string.rs b/src/array_string.rs index ae5ee86..ce98056 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -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")] diff --git a/src/errors.rs b/src/errors.rs index 798003d..5bea980 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -10,19 +10,14 @@ pub struct CapacityError { element: T, } -pub trait PubCrateNew { - fn new(elt: T) -> Self; -} - -impl PubCrateNew for CapacityError { - fn new(element: T) -> CapacityError { +impl CapacityError { + /// Create a new `CapacityError` from `element`. + pub fn new(element: T) -> CapacityError { CapacityError { element: element, } } -} -impl CapacityError { /// Extract the overflowing element pub fn element(self) -> T { self.element diff --git a/src/lib.rs b/src/lib.rs index dacb6b4..11343b8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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;