mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-08 09:38:26 +03:00
DSTify Str + impl Str for &S where S: Str
This commit is contained in:
+8
-3
@@ -1277,14 +1277,19 @@ fn slice_or_fail<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
|
||||
}
|
||||
|
||||
/// Any string that can be represented as a slice
|
||||
pub trait Str {
|
||||
pub trait Str for Sized? {
|
||||
/// Work with `self` as a slice.
|
||||
fn as_slice<'a>(&'a self) -> &'a str;
|
||||
}
|
||||
|
||||
impl<'a> Str for &'a str {
|
||||
impl Str for str {
|
||||
#[inline]
|
||||
fn as_slice<'a>(&'a self) -> &'a str { *self }
|
||||
fn as_slice<'a>(&'a self) -> &'a str { self }
|
||||
}
|
||||
|
||||
impl<'a, Sized? S> Str for &'a S where S: Str {
|
||||
#[inline]
|
||||
fn as_slice(&self) -> &str { Str::as_slice(*self) }
|
||||
}
|
||||
|
||||
/// Methods for string slices
|
||||
|
||||
Reference in New Issue
Block a user