Skip to content

Commit eccdd50

Browse files
committed
Merge pull request #2 from pfalabella/breakage-orphan
Follow rust/std changes - Rename deriving to derive - Provide IntoString in this crate instead of std - See nikomatsakis/rust@c61a009 for old_orphan_check
2 parents 9284c9c + a1755b7 commit eccdd50

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/lib.rs

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,21 @@
1212

1313
//! Operations on ASCII strings and characters
1414
15-
#![feature(macro_rules, globs, default_type_params)]
15+
#![feature(macro_rules, globs, default_type_params, old_orphan_check)]
16+
// added old_orphan_check to work around https://github.com/rust-lang/rust/issues/20477
17+
1618
#![unstable = "unsure about placement and naming"]
1719
#![allow(deprecated)]
1820

1921
//use std::kinds::Sized;
22+
2023
use std::fmt;
2124
use std::mem;
2225
use std::borrow::BorrowFrom;
2326
use std::ascii::AsciiExt;
2427

25-
2628
/// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero.
27-
#[deriving(Clone, PartialEq, PartialOrd, Ord, Eq, Hash, Copy)]
29+
#[derive(Clone, PartialEq, PartialOrd, Ord, Eq, Hash, Copy)]
2830
pub struct Ascii { chr: u8 }
2931

3032
impl Ascii {
@@ -144,7 +146,7 @@ impl<'a> fmt::Show for Ascii {
144146

145147
/// Trait for converting into an ascii type.
146148
#[experimental = "may be replaced by generic conversion traits"]
147-
pub trait AsciiCast<T, U = Self> for Sized?: AsciiExt<U> {
149+
pub trait AsciiCast<T, U = Self> : AsciiExt<U> {
148150
/// Convert to an ascii type, return Err(()) on non-ASCII input.
149151
#[inline]
150152
fn to_ascii(&self) -> Result<T, ()> {
@@ -193,7 +195,7 @@ impl AsciiCast<Ascii> for char {
193195

194196
/// Trait for copyless casting to an ascii vector.
195197
#[experimental = "may be replaced by generic conversion traits"]
196-
pub trait OwnedAsciiCast<Sized? T, U = Self>
198+
pub trait OwnedAsciiCast<T: ?Sized, U = Self> : Sized
197199
where T: BorrowFrom<Self> + AsciiExt<U> {
198200
/// Take ownership and cast to an ascii vector. Return Err(()) on non-ASCII input.
199201
#[inline]
@@ -236,10 +238,17 @@ impl OwnedAsciiCast<[u8]> for Vec<u8> {
236238
}
237239
}
238240

241+
/// Trait for converting a type to a string, consuming it in the process.
242+
#[experimental = "may be replaced by generic conversion traits"]
243+
pub trait IntoString {
244+
/// Consume and convert to a string.
245+
fn into_string(self) -> String;
246+
}
247+
239248
/// Trait for converting an ascii type to a string. Needed to convert
240249
/// `&[Ascii]` to `&str`.
241250
#[experimental = "may be replaced by generic conversion traits"]
242-
pub trait AsciiStr for Sized? {
251+
pub trait AsciiStr {
243252
/// Convert to a string.
244253
fn as_str<'a>(&'a self) -> &'a str;
245254

0 commit comments

Comments
 (0)