Skip to content

Commit

Permalink
rustup 2015-01-02
Browse files Browse the repository at this point in the history
  • Loading branch information
pfalabella committed Jan 3, 2015
1 parent 9284c9c commit a1755b7
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,21 @@

//! Operations on ASCII strings and characters
#![feature(macro_rules, globs, default_type_params)]
#![feature(macro_rules, globs, default_type_params, old_orphan_check)]
// added old_orphan_check to work around https://github.com/rust-lang/rust/issues/20477

#![unstable = "unsure about placement and naming"]
#![allow(deprecated)]

//use std::kinds::Sized;

use std::fmt;
use std::mem;
use std::borrow::BorrowFrom;
use std::ascii::AsciiExt;


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

impl Ascii {
Expand Down Expand Up @@ -144,7 +146,7 @@ impl<'a> fmt::Show for Ascii {

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

/// Trait for copyless casting to an ascii vector.
#[experimental = "may be replaced by generic conversion traits"]
pub trait OwnedAsciiCast<Sized? T, U = Self>
pub trait OwnedAsciiCast<T: ?Sized, U = Self> : Sized

This comment has been minimized.

Copy link
@tomprogrammer

tomprogrammer Jan 4, 2015

For now that's ok, in general I'd like to move the bounds completely into the where clause if there is one.
It even seems there is a bug because T: ?Sized can't be moved into the where clause without complaints by rustc.
I will check that tomorrow. Reference: rust-lang/rust#20503

where T: BorrowFrom<Self> + AsciiExt<U> {
/// Take ownership and cast to an ascii vector. Return Err(()) on non-ASCII input.
#[inline]
Expand Down Expand Up @@ -236,10 +238,17 @@ impl OwnedAsciiCast<[u8]> for Vec<u8> {
}
}

/// Trait for converting a type to a string, consuming it in the process.
#[experimental = "may be replaced by generic conversion traits"]
pub trait IntoString {
/// Consume and convert to a string.
fn into_string(self) -> String;
}

/// Trait for converting an ascii type to a string. Needed to convert
/// `&[Ascii]` to `&str`.
#[experimental = "may be replaced by generic conversion traits"]
pub trait AsciiStr for Sized? {
pub trait AsciiStr {
/// Convert to a string.
fn as_str<'a>(&'a self) -> &'a str;

Expand Down

0 comments on commit a1755b7

Please sign in to comment.