Skip to content

Commit 5554a23

Browse files
author
Thomas Bahn
committed
Follow rust std: Borrow replaces BorrowFrom
1 parent cb100bb commit 5554a23

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/lib.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
1515
use std::fmt;
1616
use std::mem;
17-
use std::borrow::BorrowFrom;
17+
use std::borrow::Borrow;
1818
use std::ascii::AsciiExt;
1919

2020
/// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
@@ -207,16 +207,13 @@ impl AsciiCast for char {
207207
}
208208

209209
/// Trait for copyless casting to an ascii vector.
210-
pub trait OwnedAsciiCast<T: ?Sized, U = Self> : Sized
211-
where T: BorrowFrom<Self> + AsciiExt<U> {
210+
pub trait OwnedAsciiCast<T: ?Sized> : Sized + Borrow<T>
211+
where T: AsciiExt<Owned=Self> {
212212
/// Take ownership and cast to an ascii vector. On non-ASCII input return ownership of data
213213
/// that was attempted to cast to ascii in `Err(Self)`.
214214
#[inline]
215215
fn into_ascii(self) -> Result<Vec<Ascii>, Self> {
216-
if {
217-
let borrowed: &T = BorrowFrom::borrow_from(&self);
218-
borrowed.is_ascii()
219-
} {
216+
if self.borrow().is_ascii() {
220217
Ok(unsafe { self.into_ascii_nocheck() })
221218
} else {
222219
Err(self)

0 commit comments

Comments
 (0)