doc: Fix extraneous as_slice()'s in docstrings
This commit is contained in:
parent
061d84399e
commit
7981aa6ac9
7 changed files with 24 additions and 24 deletions
|
@ -22,9 +22,9 @@ fn write_info(info: &Info) -> Result<(), IoError> {
|
||||||
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
|
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
|
||||||
Open, Write);
|
Open, Write);
|
||||||
// Early return on error
|
// Early return on error
|
||||||
try!(file.write_line(format!("name: {}", info.name).as_slice()));
|
try!(file.write_line(&format!("name: {}", info.name)));
|
||||||
try!(file.write_line(format!("age: {}", info.age).as_slice()));
|
try!(file.write_line(&format!("age: {}", info.age)));
|
||||||
try!(file.write_line(format!("rating: {}", info.rating).as_slice()));
|
try!(file.write_line(&format!("rating: {}", info.rating)));
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
@ -44,15 +44,15 @@ fn write_info(info: &Info) -> Result<(), IoError> {
|
||||||
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
|
let mut file = File::open_mode(&Path::new("my_best_friends.txt"),
|
||||||
Open, Write);
|
Open, Write);
|
||||||
// Early return on error
|
// Early return on error
|
||||||
match file.write_line(format!("name: {}", info.name).as_slice()) {
|
match file.write_line(&format!("name: {}", info.name)) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e)
|
||||||
}
|
}
|
||||||
match file.write_line(format!("age: {}", info.age).as_slice()) {
|
match file.write_line(&format!("age: {}", info.age)) {
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
Err(e) => return Err(e)
|
Err(e) => return Err(e)
|
||||||
}
|
}
|
||||||
return file.write_line(format!("rating: {}", info.rating).as_slice());
|
return file.write_line(&format!("rating: {}", info.rating));
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -198,7 +198,7 @@
|
||||||
//! // for details, and the function `pad` can be used to pad strings.
|
//! // for details, and the function `pad` can be used to pad strings.
|
||||||
//! let decimals = f.precision().unwrap_or(3);
|
//! let decimals = f.precision().unwrap_or(3);
|
||||||
//! let string = f64::to_str_exact(magnitude, decimals);
|
//! let string = f64::to_str_exact(magnitude, decimals);
|
||||||
//! f.pad_integral(true, "", string.as_slice())
|
//! f.pad_integral(true, "", &string)
|
||||||
//! }
|
//! }
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -139,7 +139,7 @@ impl String {
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// let input = b"Hello \xF0\x90\x80World";
|
/// let input = b"Hello \xF0\x90\x80World";
|
||||||
/// let output = String::from_utf8_lossy(input);
|
/// let output = String::from_utf8_lossy(input);
|
||||||
/// assert_eq!(output.as_slice(), "Hello \u{FFFD}World");
|
/// assert_eq!(output, "Hello \u{FFFD}World");
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> Cow<'a, str> {
|
pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> Cow<'a, str> {
|
||||||
|
@ -355,7 +355,7 @@ impl String {
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut s = String::from_str("foo");
|
/// let mut s = String::from_str("foo");
|
||||||
/// s.push_str("bar");
|
/// s.push_str("bar");
|
||||||
/// assert_eq!(s.as_slice(), "foobar");
|
/// assert_eq!(s, "foobar");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -450,7 +450,7 @@ impl String {
|
||||||
/// s.push('1');
|
/// s.push('1');
|
||||||
/// s.push('2');
|
/// s.push('2');
|
||||||
/// s.push('3');
|
/// s.push('3');
|
||||||
/// assert_eq!(s.as_slice(), "abc123");
|
/// assert_eq!(s, "abc123");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -503,7 +503,7 @@ impl String {
|
||||||
/// ```
|
/// ```
|
||||||
/// let mut s = String::from_str("hello");
|
/// let mut s = String::from_str("hello");
|
||||||
/// s.truncate(2);
|
/// s.truncate(2);
|
||||||
/// assert_eq!(s.as_slice(), "he");
|
/// assert_eq!(s, "he");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -622,7 +622,7 @@ impl String {
|
||||||
/// assert!(vec == &[104, 101, 108, 108, 111]);
|
/// assert!(vec == &[104, 101, 108, 108, 111]);
|
||||||
/// vec.reverse();
|
/// vec.reverse();
|
||||||
/// }
|
/// }
|
||||||
/// assert_eq!(s.as_slice(), "olleh");
|
/// assert_eq!(s, "olleh");
|
||||||
/// ```
|
/// ```
|
||||||
#[inline]
|
#[inline]
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
|
|
@ -178,13 +178,13 @@
|
||||||
//! fn write_info(info: &Info) -> Result<(), IoError> {
|
//! fn write_info(info: &Info) -> Result<(), IoError> {
|
||||||
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
|
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
|
||||||
//! // Early return on error
|
//! // Early return on error
|
||||||
//! if let Err(e) = file.write_line(format!("name: {}", info.name).as_slice()) {
|
//! if let Err(e) = file.write_line(&format!("name: {}", info.name)) {
|
||||||
//! return Err(e)
|
//! return Err(e)
|
||||||
//! }
|
//! }
|
||||||
//! if let Err(e) = file.write_line(format!("age: {}", info.age).as_slice()) {
|
//! if let Err(e) = file.write_line(&format!("age: {}", info.age)) {
|
||||||
//! return Err(e)
|
//! return Err(e)
|
||||||
//! }
|
//! }
|
||||||
//! return file.write_line(format!("rating: {}", info.rating).as_slice());
|
//! return file.write_line(&format!("rating: {}", info.rating));
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
|
@ -202,9 +202,9 @@
|
||||||
//! fn write_info(info: &Info) -> Result<(), IoError> {
|
//! fn write_info(info: &Info) -> Result<(), IoError> {
|
||||||
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
|
//! let mut file = File::open_mode(&Path::new("my_best_friends.txt"), Open, Write);
|
||||||
//! // Early return on error
|
//! // Early return on error
|
||||||
//! try!(file.write_line(format!("name: {}", info.name).as_slice()));
|
//! try!(file.write_line(&format!("name: {}", info.name)));
|
||||||
//! try!(file.write_line(format!("age: {}", info.age).as_slice()));
|
//! try!(file.write_line(&format!("age: {}", info.age)));
|
||||||
//! try!(file.write_line(format!("rating: {}", info.rating).as_slice()));
|
//! try!(file.write_line(&format!("rating: {}", info.rating)));
|
||||||
//! return Ok(());
|
//! return Ok(());
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
|
@ -46,7 +46,7 @@
|
||||||
//!
|
//!
|
||||||
//! fn print_usage(program: &str, opts: &[OptGroup]) {
|
//! fn print_usage(program: &str, opts: &[OptGroup]) {
|
||||||
//! let brief = format!("Usage: {} [options]", program);
|
//! let brief = format!("Usage: {} [options]", program);
|
||||||
//! print!("{}", usage(brief.as_slice(), opts));
|
//! print!("{}", usage(brief, opts));
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
|
@ -63,17 +63,17 @@
|
||||||
//! Err(f) => { panic!(f.to_string()) }
|
//! Err(f) => { panic!(f.to_string()) }
|
||||||
//! };
|
//! };
|
||||||
//! if matches.opt_present("h") {
|
//! if matches.opt_present("h") {
|
||||||
//! print_usage(program.as_slice(), opts);
|
//! print_usage(program, opts);
|
||||||
//! return;
|
//! return;
|
||||||
//! }
|
//! }
|
||||||
//! let output = matches.opt_str("o");
|
//! let output = matches.opt_str("o");
|
||||||
//! let input = if !matches.free.is_empty() {
|
//! let input = if !matches.free.is_empty() {
|
||||||
//! matches.free[0].clone()
|
//! matches.free[0].clone()
|
||||||
//! } else {
|
//! } else {
|
||||||
//! print_usage(program.as_slice(), opts);
|
//! print_usage(program, opts);
|
||||||
//! return;
|
//! return;
|
||||||
//! };
|
//! };
|
||||||
//! do_work(input.as_slice(), output);
|
//! do_work(input, output);
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@
|
||||||
/// let mut flags = FLAG_A | FLAG_B;
|
/// let mut flags = FLAG_A | FLAG_B;
|
||||||
/// flags.clear();
|
/// flags.clear();
|
||||||
/// assert!(flags.is_empty());
|
/// assert!(flags.is_empty());
|
||||||
/// assert_eq!(format!("{:?}", flags).as_slice(), "hi!");
|
/// assert_eq!(format!("{:?}", flags), "hi!");
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
|
@ -188,7 +188,7 @@
|
||||||
//! let json_str: String = json_obj.to_string();
|
//! let json_str: String = json_obj.to_string();
|
||||||
//!
|
//!
|
||||||
//! // Deserialize like before
|
//! // Deserialize like before
|
||||||
//! let decoded: TestStruct = json::decode(json_str.as_slice()).unwrap();
|
//! let decoded: TestStruct = json::decode(json_str)).unwrap();
|
||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue