language changes: MaybeOwned is deprecated, long live CowString!

This commit is contained in:
Kang Seonghoon 2014-11-28 21:32:14 +09:00
parent 86665d0a7f
commit 9e6576e37e
2 changed files with 8 additions and 8 deletions

View File

@ -7,7 +7,7 @@
*/ */
use std::fmt; use std::fmt;
use std::str::MaybeOwned; use std::str::SendStr;
use std::io::{IoResult, IoError, InvalidInput}; use std::io::{IoResult, IoError, InvalidInput};
use {Datelike, Timelike}; use {Datelike, Timelike};
@ -18,7 +18,7 @@ use naive::time::NaiveTime;
/// The internal workhouse for `DelayedFormat`. /// The internal workhouse for `DelayedFormat`.
fn format(w: &mut Writer, date: Option<&NaiveDate>, time: Option<&NaiveTime>, fn format(w: &mut Writer, date: Option<&NaiveDate>, time: Option<&NaiveTime>,
off: Option<&(MaybeOwned<'static>, Duration)>, fmt: &str) -> IoResult<()> { off: Option<&(SendStr, Duration)>, fmt: &str) -> IoResult<()> {
static SHORT_MONTHS: [&'static str, ..12] = static SHORT_MONTHS: [&'static str, ..12] =
["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
static LONG_MONTHS: [&'static str, ..12] = static LONG_MONTHS: [&'static str, ..12] =
@ -189,7 +189,7 @@ pub struct DelayedFormat<'a> {
/// The time view, if any. /// The time view, if any.
time: Option<NaiveTime>, time: Option<NaiveTime>,
/// The name and local-to-UTC difference for the offset (timezone), if any. /// The name and local-to-UTC difference for the offset (timezone), if any.
off: Option<(MaybeOwned<'static>, Duration)>, off: Option<(SendStr, Duration)>,
/// The format string. /// The format string.
fmt: &'a str, fmt: &'a str,
} }

View File

@ -7,7 +7,7 @@
*/ */
use std::fmt; use std::fmt;
use std::str::MaybeOwned; use std::str::SendStr;
use stdtime; use stdtime;
use {Weekday, Datelike, Timelike}; use {Weekday, Datelike, Timelike};
@ -218,7 +218,7 @@ pub trait Offset: Clone + fmt::Show {
} }
/// Returns a name or abbreviation of this offset. /// Returns a name or abbreviation of this offset.
fn name(&self) -> MaybeOwned<'static>; fn name(&self) -> SendStr;
/// Returns the *current* offset from UTC to the local time. /// Returns the *current* offset from UTC to the local time.
fn local_minus_utc(&self) -> Duration; fn local_minus_utc(&self) -> Duration;
@ -262,7 +262,7 @@ impl UTC {
} }
impl Offset for UTC { impl Offset for UTC {
fn name(&self) -> MaybeOwned<'static> { "UTC".into_maybe_owned() } fn name(&self) -> SendStr { "UTC".into_cow() }
fn local_minus_utc(&self) -> Duration { Duration::zero() } fn local_minus_utc(&self) -> Duration { Duration::zero() }
fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<UTC>> { fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<UTC>> {
@ -333,7 +333,7 @@ impl FixedOffset {
} }
impl Offset for FixedOffset { impl Offset for FixedOffset {
fn name(&self) -> MaybeOwned<'static> { "UTC".into_maybe_owned() } // XXX fn name(&self) -> SendStr { "UTC".into_cow() } // XXX
fn local_minus_utc(&self) -> Duration { Duration::seconds(self.local_minus_utc as i64) } fn local_minus_utc(&self) -> Duration { Duration::seconds(self.local_minus_utc as i64) }
fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<FixedOffset>> { fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<FixedOffset>> {
@ -429,7 +429,7 @@ impl Local {
} }
impl Offset for Local { impl Offset for Local {
fn name(&self) -> MaybeOwned<'static> { "LMT".into_maybe_owned() } // XXX XXX fn name(&self) -> SendStr { "LMT".into_cow() } // XXX XXX
fn local_minus_utc(&self) -> Duration { self.cached.local_minus_utc() } fn local_minus_utc(&self) -> Duration { self.cached.local_minus_utc() }
fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<Local>> { fn from_local_date(&self, local: &NaiveDate) -> LocalResult<Date<Local>> {