]> git.lizzy.rs Git - rust.git/commitdiff
doc: Remove all uses of `~str` from the documentation.
authorPatrick Walton <pcwalton@mimiga.net>
Thu, 15 May 2014 05:09:21 +0000 (22:09 -0700)
committerPatrick Walton <pcwalton@mimiga.net>
Fri, 16 May 2014 18:41:27 +0000 (11:41 -0700)
src/doc/complement-cheatsheet.md
src/doc/guide-macros.md
src/doc/guide-tasks.md
src/doc/po/ja/complement-cheatsheet.md.po
src/doc/po/ja/rust.md.po
src/doc/po/ja/tutorial.md.po
src/doc/rust.md
src/doc/rustdoc.md
src/doc/tutorial.md

index 5cd555cad8ea9e66517a809da0926bdd050c8a25..4670a2922cf8c6100bb51f6a4cf6548bc658484c 100644 (file)
@@ -8,7 +8,7 @@ Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr.html
 
 ~~~
 let x: int = 42;
-let y: ~str = x.to_str();
+let y: StrBuf = x.to_str().to_strbuf();
 ~~~
 
 **String to int**
@@ -22,14 +22,14 @@ let y: int = x.unwrap();
 
 **Int to string, in non-base-10**
 
-Use the `format!` syntax extension.
+Use the `format_strbuf!` syntax extension.
 
 ~~~
 let x: int = 42;
-let y: ~str = format!("{:t}", x);   // binary
-let y: ~str = format!("{:o}", x);   // octal
-let y: ~str = format!("{:x}", x);   // lowercase hexadecimal
-let y: ~str = format!("{:X}", x);   // uppercase hexadecimal
+let y: StrBuf = format_strbuf!("{:t}", x);   // binary
+let y: StrBuf = format_strbuf!("{:o}", x);   // octal
+let y: StrBuf = format_strbuf!("{:x}", x);   // lowercase hexadecimal
+let y: StrBuf = format_strbuf!("{:X}", x);   // uppercase hexadecimal
 ~~~
 
 **String to int, in non-base-10**
@@ -55,13 +55,14 @@ let x: Option<&str> = str::from_utf8(bytes);
 let y: &str = x.unwrap();
 ~~~
 
-To return an Owned String (~str) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
+To return an Owned String (StrBuf) use the str helper function [`from_utf8_owned`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).
 
 ~~~
 use std::str;
 
-let x: Result<~str,~[u8]> = str::from_utf8_owned(~[104u8,105u8]);
-let y: ~str = x.unwrap();
+let x: Result<StrBuf,~[u8]> =
+    str::from_utf8_owned(~[104u8,105u8]).map(|x| x.to_strbuf());
+let y: StrBuf = x.unwrap();
 ~~~
 
 To return a [`MaybeOwned`](http://static.rust-lang.org/doc/master/std/str/enum.MaybeOwned.html) use the str helper function [`from_utf8_lossy`](http://static.rust-lang.org/doc/master/std/str/fn.from_utf8_owned.html).  This function also replaces non-valid utf-8 sequences with U+FFFD replacement character.
@@ -181,7 +182,7 @@ enum Closed {}
 Phantom types are useful for enforcing state at compile time. For example:
 
 ~~~
-struct Door<State>(~str);
+struct Door<State>(StrBuf);
 
 struct Open;
 struct Closed;
@@ -194,13 +195,13 @@ fn open(Door(name): Door<Closed>) -> Door<Open> {
     Door::<Open>(name)
 }
 
-let _ = close(Door::<Open>("front".to_owned()));
+let _ = close(Door::<Open>("front".to_strbuf()));
 ~~~
 
 Attempting to close a closed door is prevented statically:
 
 ~~~ {.ignore}
-let _ = close(Door::<Closed>("front".to_owned())); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
+let _ = close(Door::<Closed>("front".to_strbuf())); // error: mismatched types: expected `main::Door<main::Open>` but found `main::Door<main::Closed>`
 ~~~
 
 # FFI (Foreign Function Interface)
index 303a32289b0ea47a7c4c3d5be928024b0ee21f1c..66935300f18d9ccc2bd5ec1855075cc85d32accf 100644 (file)
@@ -85,7 +85,7 @@ To take as an argument a fragment of Rust code, write `$` followed by a name
   `foo`.)
 * `expr` (an expression. Examples: `2 + 2`; `if true then { 1 } else { 2 }`;
   `f(42)`.)
-* `ty` (a type. Examples: `int`, `~[(char, ~str)]`, `&T`.)
+* `ty` (a type. Examples: `int`, `~[(char, StrBuf)]`, `&T`.)
 * `pat` (a pattern, usually appearing in a `match` or on the left-hand side of
   a declaration. Examples: `Some(t)`; `(17, 'a')`; `_`.)
 * `block` (a sequence of actions. Example: `{ log(error, "hi"); return 12; }`)
index 78a191ac1e37eddb2de9661743c07264c0cd4ff2..8df11c59f60ef8271a0f0b25add20389feb311b4 100644 (file)
@@ -463,11 +463,11 @@ Here is the function that implements the child task:
 ~~~
 extern crate sync;
 # fn main() {
-fn stringifier(channel: &sync::DuplexStream<~str, uint>) {
+fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) {
     let mut value: uint;
     loop {
         value = channel.recv();
-        channel.send(value.to_str());
+        channel.send(value.to_str().to_strbuf());
         if value == 0 { break; }
     }
 }
@@ -488,11 +488,11 @@ Here is the code for the parent task:
 extern crate sync;
 # use std::task::spawn;
 # use sync::DuplexStream;
-# fn stringifier(channel: &sync::DuplexStream<~str, uint>) {
+# fn stringifier(channel: &sync::DuplexStream<StrBuf, uint>) {
 #     let mut value: uint;
 #     loop {
 #         value = channel.recv();
-#         channel.send(value.to_str());
+#         channel.send(value.to_str().to_strbuf());
 #         if value == 0u { break; }
 #     }
 # }
@@ -505,13 +505,13 @@ spawn(proc() {
 });
 
 from_child.send(22);
-assert!(from_child.recv() == "22".to_owned());
+assert!(from_child.recv().as_slice() == "22");
 
 from_child.send(23);
 from_child.send(0);
 
-assert!(from_child.recv() == "23".to_owned());
-assert!(from_child.recv() == "0".to_owned());
+assert!(from_child.recv().as_slice() == "23");
+assert!(from_child.recv().as_slice() == "0");
 
 # }
 ~~~
index f387f3be9f36311f38c1fa133e774070c6967e0a..4ce4d1697be0bd94f1dfe21285fe96ad890a7c2d 100644 (file)
@@ -34,7 +34,7 @@ msgstr ""
 #, fuzzy
 #| msgid ""
 #| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
-msgid "~~~ let x: int = 42; let y: ~str = x.to_str(); ~~~"
+msgid "~~~ let x: int = 42; let y: StrBuf = x.to_str(); ~~~"
 msgstr ""
 "~~~~\n"
 "let x: f64 = 4.0;\n"
@@ -96,7 +96,7 @@ msgstr ""
 #, fuzzy
 #| msgid ""
 #| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
-msgid "let x: int = 42; let y: ~str = x.to_str_radix(16); ~~~"
+msgid "let x: int = 42; let y: StrBuf = x.to_str_radix(16); ~~~"
 msgstr ""
 "~~~~\n"
 "let x: f64 = 4.0;\n"
index 758d9863b0a35acf54880c072612f3c2152fb0e4..b23f130f2663887d0f5402d8448c294c13a726dd 100644 (file)
@@ -1641,7 +1641,7 @@ msgstr "## 最小限の例"
 msgid ""
 "~~~~\n"
 "trait Printable {\n"
-"  fn to_string(&self) -> ~str;\n"
+"  fn to_string(&self) -> StrBuf;\n"
 "}\n"
 msgstr ""
 "~~~~ {.ignore}\n"
@@ -1656,7 +1656,7 @@ msgstr ""
 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
 msgid ""
 "impl Printable for int {\n"
-"  fn to_string(&self) -> ~str { self.to_str() }\n"
+"  fn to_string(&self) -> StrBuf { self.to_str() }\n"
 "}\n"
 msgstr ""
 "~~~~ {.ignore}\n"
@@ -1702,7 +1702,7 @@ msgstr "# クロージャ"
 msgid ""
 "~~~~\n"
 "trait Printable {\n"
-"  fn make_string(&self) -> ~str;\n"
+"  fn make_string(&self) -> StrBuf;\n"
 "}\n"
 msgstr ""
 "~~~~ {.ignore}\n"
@@ -1716,8 +1716,8 @@ msgstr ""
 #, fuzzy, no-wrap
 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
 msgid ""
-"impl Printable for ~str {\n"
-"    fn make_string(&self) -> ~str {\n"
+"impl Printable for StrBuf {\n"
+"    fn make_string(&self) -> StrBuf {\n"
 "        (*self).clone()\n"
 "    }\n"
 "}\n"
index 721b5b2b659d1a376f3d14de09f5f3905bf99bea..96514e99b86b1682eeda44ca65db46cdf524907d 100644 (file)
@@ -3755,15 +3755,15 @@ msgstr ""
 #| msgid ""
 #| "Traits may be implemented for specific types with [impls]. An impl that "
 #| "implements a trait includes the name of the trait at the start of the "
-#| "definition, as in the following impls of `Printable` for `int` and `~str`."
+#| "definition, as in the following impls of `Printable` for `int` and `StrBuf`."
 msgid ""
 "Traits may be implemented for specific types with [impls]. An impl for a "
 "particular trait gives an implementation of the methods that trait "
 "provides.  For instance, the following impls of `Printable` for `int` and "
-"`~str` give implementations of the `print` method."
+"`StrBuf` give implementations of the `print` method."
 msgstr ""
 "[impl][impls] により特定の型にトレイトを実装することができます。トレイトを実"
-"装する impl は、以下の `Printable` の `int` と `~str` に対する実装のように、"
+"装する impl は、以下の `Printable` の `int` と `StrBuf` に対する実装のように、"
 "定義の先頭にトレイトの名前を含みます。"
 
 #. type: Plain text
@@ -3776,7 +3776,7 @@ msgstr "[impls]: #メソッド"
 #, fuzzy, no-wrap
 #| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
 msgid ""
-"impl Printable for ~str {\n"
+"impl Printable for StrBuf {\n"
 "    fn print(&self) { println!(\"{}\", *self) }\n"
 "}\n"
 msgstr ""
index 838ddca042dfc661c2b5f70676bbdaec59659565..4986ad1ba99f55809a4d11b13bed018fd2ca909d 100644 (file)
@@ -473,7 +473,7 @@ Two examples of paths with type arguments:
 # struct HashMap<K, V>;
 # fn f() {
 # fn id<T>(t: T) -> T { t }
-type T = HashMap<int,~str>;  // Type arguments used in a type expression
+type T = HashMap<int,StrBuf>;  // Type arguments used in a type expression
 let x = id::<int>(10);       // Type arguments used in a call expression
 # }
 ~~~~
@@ -1259,12 +1259,12 @@ Enumeration constructors can have either named or unnamed fields:
 
 ~~~~
 enum Animal {
-    Dog (~str, f64),
-    Cat { name: ~str, weight: f64 }
+    Dog (StrBuf, f64),
+    Cat { name: StrBuf, weight: f64 }
 }
 
-let mut a: Animal = Dog("Cocoa".to_owned(), 37.2);
-a = Cat{ name: "Spotty".to_owned(), weight: 2.7 };
+let mut a: Animal = Dog("Cocoa".to_strbuf(), 37.2);
+a = Cat { name: "Spotty".to_strbuf(), weight: 2.7 };
 ~~~~
 
 In this example, `Cat` is a _struct-like enum variant_,
@@ -2081,7 +2081,7 @@ These are functions:
 * `str_eq`
   : Compare two strings (`&str`) for equality.
 * `uniq_str_eq`
-  : Compare two owned strings (`~str`) for equality.
+  : Compare two owned strings (`StrBuf`) for equality.
 * `strdup_uniq`
   : Return a new unique string
     containing a copy of the contents of a unique string.
@@ -3309,7 +3309,7 @@ A value of type `str` is a Unicode string,
 represented as a vector of 8-bit unsigned bytes holding a sequence of UTF-8 codepoints.
 Since `str` is of unknown size, it is not a _first class_ type,
 but can only be instantiated through a pointer type,
-such as `&str` or `~str`.
+such as `&str` or `StrBuf`.
 
 ### Tuple types
 
@@ -3573,11 +3573,11 @@ An example of an object type:
 
 ~~~~
 trait Printable {
-  fn to_string(&self) -> ~str;
+  fn to_string(&self) -> StrBuf;
 }
 
 impl Printable for int {
-  fn to_string(&self) -> ~str { self.to_str() }
+  fn to_string(&self) -> StrBuf { self.to_str().to_strbuf() }
 }
 
 fn print(a: Box<Printable>) {
@@ -3618,17 +3618,17 @@ example, in:
 
 ~~~~
 trait Printable {
-  fn make_string(&self) -> ~str;
+  fn make_string(&self) -> StrBuf;
 }
 
-impl Printable for ~str {
-    fn make_string(&self) -> ~str {
+impl Printable for StrBuf {
+    fn make_string(&self) -> StrBuf {
         (*self).clone()
     }
 }
 ~~~~
 
-`self` refers to the value of type `~str` that is the receiver for a
+`self` refers to the value of type `StrBuf` that is the receiver for a
 call to the method `make_string`.
 
 ## Type kinds
index 06ee875f6d6210dc5707d39ad13cf3fa25a96eae..3b7f4e1bf5013940cbd34d081116dc8263abd2b8 100644 (file)
@@ -26,7 +26,7 @@ comments":
 pub struct Widget {
        /// All widgets have a purpose (this is a doc comment, and will show up
        /// the field's documentation).
-       purpose: ~str,
+       purpose: StrBuf,
        /// Humans are not allowed to understand some widgets
        understandable: bool
 }
index 7dd31f9cc77c6a16bf9f026396e7d3fd1ad2a38f..ad77b90e79b7023110ca784fc020158c4dc7b47b 100644 (file)
@@ -2213,7 +2213,7 @@ don't provide any methods.
 Traits may be implemented for specific types with [impls]. An impl for
 a particular trait gives an implementation of the methods that
 trait provides.  For instance, the following impls of
-`Printable` for `int` and `~str` give implementations of the `print`
+`Printable` for `int` and `StrBuf` give implementations of the `print`
 method.
 
 [impls]: #methods
@@ -2224,12 +2224,12 @@ impl Printable for int {
     fn print(&self) { println!("{:?}", *self) }
 }
 
-impl Printable for ~str {
+impl Printable for StrBuf {
     fn print(&self) { println!("{}", *self) }
 }
 
 # 1.print();
-# ("foo".to_owned()).print();
+# ("foo".to_strbuf()).print();
 ~~~~
 
 Methods defined in an impl for a trait may be called just like
@@ -2270,7 +2270,7 @@ trait Printable {
 
 impl Printable for int {}
 
-impl Printable for ~str {
+impl Printable for StrBuf {
     fn print(&self) { println!("{}", *self) }
 }
 
@@ -2279,7 +2279,7 @@ impl Printable for bool {}
 impl Printable for f32 {}
 
 # 1.print();
-# ("foo".to_owned()).print();
+# ("foo".to_strbuf()).print();
 # true.print();
 # 3.14159.print();
 ~~~~
@@ -2291,7 +2291,7 @@ provided in the trait definition.  Depending on the trait, default
 methods can save a great deal of boilerplate code from having to be
 written in impls.  Of course, individual impls can still override the
 default method for `print`, as is being done above in the impl for
-`~str`.
+`StrBuf`.
 
 ## Type-parameterized traits