From ebdc3046a4419b6d97e1c865705ed59ee1058f5a Mon Sep 17 00:00:00 2001 From: areski Date: Thu, 23 Oct 2014 00:44:17 +0200 Subject: [PATCH] Fixed single quote around string slice and simplify example This patch contains a fix for: - single quote around string slice - string: String is confusing for newbies and it's more readble if the argument name is different that the argument type name --- src/doc/guide-strings.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/doc/guide-strings.md b/src/doc/guide-strings.md index 44fc0d830447..1c7cb1a3b4eb 100644 --- a/src/doc/guide-strings.md +++ b/src/doc/guide-strings.md @@ -14,8 +14,8 @@ Rust has two main types of strings: `&str` and `String`. # &str -The first kind is a `&str`. This is pronounced a 'string slice.' String literals -are of the type `&str`: +The first kind is a `&str`. This is pronounced a 'string slice'. +String literals are of the type `&str`: ```{rust} let string = "Hello there."; @@ -121,8 +121,8 @@ Both of these lines will print `12`. To compare a String to a constant string, prefer `as_slice()`... ```{rust} -fn compare(string: String) { - if string.as_slice() == "Hello" { +fn compare(x: String) { + if x.as_slice() == "Hello" { println!("yes"); } } @@ -131,8 +131,8 @@ fn compare(string: String) { ... over `to_string()`: ```{rust} -fn compare(string: String) { - if string == "Hello".to_string() { +fn compare(x: String) { + if x == "Hello".to_string() { println!("yes"); } }