@@ -96,8 +96,7 @@ prerequisites, something along these lines should work. Building from source on
96
96
Windows requires some extra steps: please see the
97
97
[ getting started] [ wiki-get-started ] page on the Rust wiki.
98
98
99
- ~~~~
100
- ## notrust
99
+ ~~~~ {.notrust}
101
100
$ wget http://dl.rust-lang.org/dist/rust-0.1.tar.gz
102
101
$ tar -xzf rust-0.1.tar.gz
103
102
$ cd rust-0.1
@@ -144,8 +143,7 @@ If you modify the program to make it invalid (for example, change the
144
143
function to an unknown name), and then compile it, you'll see an error
145
144
message like this:
146
145
147
- ~~~~
148
- ## notrust
146
+ ~~~~ {.notrust}
149
147
hello.rs:2:4: 2:16 error: unresolved name: io::print_it
150
148
hello.rs:2 io::print_it("hello world from '" + args[0] + "'!");
151
149
^~~~~~~~~~~~
@@ -511,8 +509,7 @@ BSD-style license). Finally, you can have a name followed by a
511
509
comma-separated list of nested attributes, as in the ` cfg ` example
512
510
above, or in this [ crate] ( #modules-and-crates ) metadata declaration:
513
511
514
- ~~~~
515
- ## ignore
512
+ ~~~~ {.ignore}
516
513
#[link(name = "std",
517
514
vers = "0.1",
518
515
url = "http://rust-lang.org/src/std")];
@@ -1595,8 +1592,7 @@ parameter `T`, can you copy values of that type? In Rust, you can't,
1595
1592
unless you explicitly declare that type parameter to have copyable
1596
1593
'kind'. A kind is a type of type.
1597
1594
1598
- ~~~~
1599
- ## ignore
1595
+ ~~~~ {.ignore}
1600
1596
// This does not compile
1601
1597
fn head_bad<T>(v: [T]) -> T { v[0] }
1602
1598
// This does
@@ -1687,8 +1683,7 @@ It is also possible to include multiple files in a crate. For this
1687
1683
purpose, you create a ` .rc ` crate file, which references any number of
1688
1684
` .rs ` code files. A crate file could look like this:
1689
1685
1690
- ~~~~
1691
- ## ignore
1686
+ ~~~~ {.ignore}
1692
1687
#[link(name = "farm", vers = "2.5", author = "mjh")];
1693
1688
mod cow;
1694
1689
mod chicken;
@@ -1707,8 +1702,7 @@ later.
1707
1702
To have a nested directory structure for your source files, you can
1708
1703
nest mods in your ` .rc ` file:
1709
1704
1710
- ~~~~
1711
- ## ignore
1705
+ ~~~~ {.ignore}
1712
1706
mod poultry {
1713
1707
mod chicken;
1714
1708
mod turkey;
@@ -1736,8 +1730,7 @@ crate library with the right name.
1736
1730
It is possible to provide more specific information when using an
1737
1731
external crate.
1738
1732
1739
- ~~~~
1740
- ## ignore
1733
+ ~~~~ {.ignore}
1741
1734
use myfarm (name = "farm", vers = "2.7");
1742
1735
~~~~
1743
1736
@@ -1750,8 +1743,7 @@ local name `myfarm`.
1750
1743
1751
1744
Our example crate declared this set of ` link ` attributes:
1752
1745
1753
- ~~~~
1754
- ## ignore
1746
+ ~~~~ {.ignore}
1755
1747
#[link(name = "farm", vers = "2.5", author = "mjh")];
1756
1748
~~~~
1757
1749
@@ -1780,8 +1772,7 @@ these two files:
1780
1772
fn world() -> str { "world" }
1781
1773
~~~~
1782
1774
1783
- ~~~~
1784
- ## ignore
1775
+ ~~~~ {.ignore}
1785
1776
// main.rs
1786
1777
use std;
1787
1778
use mylib;
@@ -1790,8 +1781,7 @@ fn main() { io::println("hello " + mylib::world()); }
1790
1781
1791
1782
Now compile and run like this (adjust to your platform if necessary):
1792
1783
1793
- ~~~~
1794
- ## notrust
1784
+ ~~~~ {.notrust}
1795
1785
> rustc --lib mylib.rs
1796
1786
> rustc main.rs -L .
1797
1787
> ./main
@@ -2133,8 +2123,7 @@ hash of its first command-line argument, which it then converts to a
2133
2123
hexadecimal string and prints to standard output. If you have the
2134
2124
OpenSSL libraries installed, it should 'just work'.
2135
2125
2136
- ~~~~
2137
- ## xfail-test
2126
+ ~~~~ {.xfail-test}
2138
2127
use std;
2139
2128
2140
2129
native mod crypto {
@@ -2164,8 +2153,7 @@ fn main(args: [str]) {
2164
2153
Before we can call ` SHA1 ` , we have to declare it. That is what this
2165
2154
part of the program is responsible for:
2166
2155
2167
- ~~~~
2168
- ## xfail-test
2156
+ ~~~~ {.xfail-test}
2169
2157
native mod crypto {
2170
2158
fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8;
2171
2159
}
@@ -2180,8 +2168,7 @@ in a platform-specific way (`libcrypto.so` on Linux, for example), and
2180
2168
link that in. If you want the module to have a different name from the
2181
2169
actual library, you can use the ` "link_name" ` attribute, like:
2182
2170
2183
- ~~~~
2184
- ## xfail-test
2171
+ ~~~~ {.xfail-test}
2185
2172
#[link_name = "crypto"]
2186
2173
native mod something {
2187
2174
fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8;
@@ -2213,8 +2200,7 @@ or `"stdcall"`. Other conventions may be defined in the future.
2213
2200
The native ` SHA1 ` function is declared to take three arguments, and
2214
2201
return a pointer.
2215
2202
2216
- ~~~~
2217
- ## xfail-test
2203
+ ~~~~ {.xfail-test}
2218
2204
# native mod crypto {
2219
2205
fn SHA1(src: *u8, sz: uint, out: *u8) -> *u8;
2220
2206
# }
@@ -2547,8 +2533,7 @@ When you compile the program normally, the `test_twice` function will
2547
2533
not be included. To compile and run such tests, compile with the
2548
2534
` --test ` flag, and then run the result:
2549
2535
2550
- ~~~~
2551
- ## notrust
2536
+ ~~~~ {.notrust}
2552
2537
> rustc --test twice.rs
2553
2538
> ./twice
2554
2539
running 1 tests
@@ -2559,8 +2544,7 @@ result: ok. 1 passed; 0 failed; 0 ignored
2559
2544
Or, if we change the file to fail, for example by replacing ` x + x `
2560
2545
with ` x + 1 ` :
2561
2546
2562
- ~~~~
2563
- ## notrust
2547
+ ~~~~ {.notrust}
2564
2548
running 1 tests
2565
2549
test test_twice ... FAILED
2566
2550
failures:
0 commit comments