@@ -1214,32 +1214,6 @@ let your_crayons = ~[banana_mania, beaver, bittersweet];
1214
1214
my_crayons += your_crayons;
1215
1215
~~~~
1216
1216
1217
- ## Strings
1218
-
1219
- The ` ~str ` type in Rust is represented exactly the same way as a unique
1220
- vector of immutable bytes (` ~[u8] ` ). This sequence of bytes is
1221
- interpreted as an UTF-8 encoded sequence of characters. This has the
1222
- advantage that UTF-8 encoded I/O (which should really be the default
1223
- for modern systems) is very fast, and that strings have, for most
1224
- intents and purposes, a nicely compact representation. It has the
1225
- disadvantage that you only get constant-time access by byte, not by
1226
- character.
1227
-
1228
- ~~~~
1229
- let huh = ~"what?";
1230
- let que: u8 = huh[4]; // indexing a string returns a `u8`
1231
- assert que == '?' as u8;
1232
- ~~~~
1233
-
1234
- A lot of algorithms don't need constant-time indexed access (they
1235
- iterate over all characters, which ` str::chars ` helps with), and
1236
- for those that do, many don't need actual characters, and can operate
1237
- on bytes. For algorithms that do really need to index by character,
1238
- there are core library functions available.
1239
-
1240
- > *** Note:*** like vectors, strings will soon be allocatable in
1241
- > the local heap and on the stack, in addition to the exchange heap.
1242
-
1243
1217
## Vector and string methods
1244
1218
1245
1219
Both vectors and strings support a number of useful
0 commit comments