diff --git a/src/libextra/arc.rs b/src/libextra/arc.rs index 28a067a782b..be55af697c6 100644 --- a/src/libextra/arc.rs +++ b/src/libextra/arc.rs @@ -17,7 +17,7 @@ * In this example, a large vector of floats is shared between several tasks. * With simple pipes, without Arc, a copy would have to be made for each task. * - * ~~~ {.rust} + * ```rust * extern mod std; * use extra::arc; * let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random()); @@ -34,7 +34,7 @@ * // Work with the local numbers * } * } - * ~~~ + * ``` */ #[allow(missing_doc)]; @@ -440,7 +440,7 @@ impl RWArc { * * # Example * - * ~~~ {.rust} + * ```rust * do arc.write_downgrade |mut write_token| { * do write_token.write_cond |state, condvar| { * ... exclusive access with mutable state ... @@ -450,7 +450,7 @@ impl RWArc { * ... shared access with immutable state ... * } * } - * ~~~ + * ``` */ pub fn write_downgrade(&self, blk: &fn(v: RWWriteMode) -> U) -> U { unsafe { diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index 191ecbe8d16..f26554c42f4 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -62,7 +62,7 @@ impl<'self> ToBase64 for &'self [u8] { * * # Example * - * ~~~ {.rust} + * ```rust * extern mod extra; * use extra::base64::{ToBase64, standard}; * @@ -70,7 +70,7 @@ impl<'self> ToBase64 for &'self [u8] { * let str = [52,32].to_base64(standard); * printfln!("%s", str); * } - * ~~~ + * ``` */ fn to_base64(&self, config: Config) -> ~str { let bytes = match config.char_set { @@ -170,7 +170,7 @@ impl<'self> FromBase64 for &'self str { * * This converts a string literal to base64 and back. * - * ~~~ {.rust} + * ```rust * extern mod extra; * use extra::base64::{ToBase64, FromBase64, standard}; * use std::str; @@ -183,7 +183,7 @@ impl<'self> FromBase64 for &'self str { * let result_str = str::from_utf8(bytes); * printfln!("%s", result_str); * } - * ~~~ + * ``` */ fn from_base64(&self) -> Result<~[u8], ~str> { let mut r = ~[]; diff --git a/src/libextra/flatpipes.rs b/src/libextra/flatpipes.rs index d102f6068f5..886a28ac979 100644 --- a/src/libextra/flatpipes.rs +++ b/src/libextra/flatpipes.rs @@ -25,7 +25,7 @@ ports and channels. This example sends boxed integers across tasks using serialization. -~~~ {.rust} +```rust let (port, chan) = serial::pipe_stream(); do task::spawn || { @@ -37,7 +37,7 @@ do task::spawn || { for i in range(0, 10) { assert @i == port.recv() } -~~~ + ``` # Safety Note diff --git a/src/libextra/future.rs b/src/libextra/future.rs index 4e8bc37891d..72c6db6fb72 100644 --- a/src/libextra/future.rs +++ b/src/libextra/future.rs @@ -14,13 +14,13 @@ * * # Example * - * ~~~ {.rust} + * ```rust * # fn fib(n: uint) -> uint {42}; * # fn make_a_sandwich() {}; * let mut delayed_fib = extra::future::spawn (|| fib(5000) ); * make_a_sandwich(); * printfln!("fib(5000) = %?", delayed_fib.get()) - * ~~~ + * ``` */ #[allow(missing_doc)]; diff --git a/src/libextra/glob.rs b/src/libextra/glob.rs index 72368aeff23..76ac7c91832 100644 --- a/src/libextra/glob.rs +++ b/src/libextra/glob.rs @@ -51,18 +51,18 @@ pub struct GlobIterator { * Consider a directory `/media/pictures` containing only the files `kittens.jpg`, * `puppies.jpg` and `hamsters.gif`: * - * ~~~ {.rust} + * ```rust * for path in glob("/media/pictures/*.jpg") { * println(path.to_str()); * } - * ~~~ + * ``` * * The above code will print: * - * ~~~ + * ``` * /media/pictures/kittens.jpg * /media/pictures/puppies.jpg - * ~~~ + * ``` */ pub fn glob(pattern: &str) -> GlobIterator { glob_with(pattern, MatchOptions::new()) @@ -270,11 +270,11 @@ impl Pattern { * * # Example * - * ~~~ {.rust} + * ```rust * assert!(Pattern::new("c?t").matches("cat")); * assert!(Pattern::new("k[!e]tteh").matches("kitteh")); * assert!(Pattern::new("d*g").matches("doog")); - * ~~~ + * ``` */ pub fn matches(&self, str: &str) -> bool { self.matches_with(str, MatchOptions::new()) @@ -492,13 +492,13 @@ impl MatchOptions { * * This function always returns this value: * - * ~~~ {.rust} + * ```rust * MatchOptions { * case_sensitive: true, * require_literal_separator: false. * require_literal_leading_dot: false * } - * ~~~ + * ``` */ pub fn new() -> MatchOptions { MatchOptions { diff --git a/src/libextra/hex.rs b/src/libextra/hex.rs index b93b5fb43d4..d5b89cafced 100644 --- a/src/libextra/hex.rs +++ b/src/libextra/hex.rs @@ -27,7 +27,7 @@ impl<'self> ToHex for &'self [u8] { * * # Example * - * ~~~ {.rust} + * ```rust * extern mod extra; * use extra::hex::ToHex; * @@ -35,7 +35,7 @@ impl<'self> ToHex for &'self [u8] { * let str = [52,32].to_hex(); * printfln!("%s", str); * } - * ~~~ + * ``` */ fn to_hex(&self) -> ~str { let mut v = vec::with_capacity(self.len() * 2); @@ -70,7 +70,7 @@ impl<'self> FromHex for &'self str { * * This converts a string literal to hexadecimal and back. * - * ~~~ {.rust} + * ```rust * extern mod extra; * use extra::hex::{FromHex, ToHex}; * use std::str; @@ -83,7 +83,7 @@ impl<'self> FromHex for &'self str { * let result_str = str::from_utf8(bytes); * printfln!("%s", result_str); * } - * ~~~ + * ``` */ fn from_hex(&self) -> Result<~[u8], ~str> { // This may be an overestimate if there is any whitespace diff --git a/src/libextra/sync.rs b/src/libextra/sync.rs index 99235e3029c..31ae5e70a99 100644 --- a/src/libextra/sync.rs +++ b/src/libextra/sync.rs @@ -578,7 +578,7 @@ impl RWLock { * * # Example * - * ~~~ {.rust} + * ```rust * do lock.write_downgrade |mut write_token| { * do write_token.write_cond |condvar| { * ... exclusive access ... @@ -588,7 +588,7 @@ impl RWLock { * ... shared access ... * } * } - * ~~~ + * ``` */ pub fn write_downgrade(&self, blk: &fn(v: RWLockWriteMode) -> U) -> U { // Implementation slightly different from the slicker 'write's above. diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs index 8eff9a02299..77f8edc10aa 100644 --- a/src/libextra/uuid.rs +++ b/src/libextra/uuid.rs @@ -28,7 +28,7 @@ unlikely. To create a new random (V4) UUID and print it out in hexadecimal form: -~~~ {.rust} +```rust extern mod extra; use extra::uuid::Uuid; @@ -36,7 +36,7 @@ fn main() { let uuid1 = Uuid::new_v4(); println(uuid1.to_str()); } -~~~ + ``` # Strings diff --git a/src/librustc/middle/typeck/infer/doc.rs b/src/librustc/middle/typeck/infer/doc.rs index 11bfbc63716..539418dbcb2 100644 --- a/src/librustc/middle/typeck/infer/doc.rs +++ b/src/librustc/middle/typeck/infer/doc.rs @@ -240,4 +240,4 @@ We make use of a trait-like impementation strategy to consolidate duplicated code between subtypes, GLB, and LUB computations. See the section on "Type Combining" below for details. -*/ \ No newline at end of file +*/ diff --git a/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs b/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs index 542a6af402d..3b233c9f6a8 100644 --- a/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs +++ b/src/librustpkg/testsuite/pass/src/fancy-lib/foo.rs @@ -9,4 +9,4 @@ // except according to those terms. pub fn do_nothing() { -} \ No newline at end of file +} diff --git a/src/librustpkg/testsuite/pass/src/install-paths/bench.rs b/src/librustpkg/testsuite/pass/src/install-paths/bench.rs index e1641ccf074..3d22ddc57fa 100644 --- a/src/librustpkg/testsuite/pass/src/install-paths/bench.rs +++ b/src/librustpkg/testsuite/pass/src/install-paths/bench.rs @@ -14,4 +14,4 @@ fn g() { while(x < 1000) { x += 1; } -} \ No newline at end of file +} diff --git a/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs b/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs index 542a6af402d..3b233c9f6a8 100644 --- a/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs +++ b/src/librustpkg/testsuite/pass/src/simple-lib/src/foo.rs @@ -9,4 +9,4 @@ // except according to those terms. pub fn do_nothing() { -} \ No newline at end of file +} diff --git a/src/libstd/bool.rs b/src/libstd/bool.rs index 4ef50094139..1d59e63e702 100644 --- a/src/libstd/bool.rs +++ b/src/libstd/bool.rs @@ -52,15 +52,15 @@ use to_str::ToStr; * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::not(true) * false -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::not(false) * true -* ~~~ +* ``` */ pub fn not(v: bool) -> bool { !v } @@ -69,15 +69,15 @@ pub fn not(v: bool) -> bool { !v } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::and(true, false) * false -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::and(true, true) * true -* ~~~ +* ``` */ pub fn and(a: bool, b: bool) -> bool { a && b } @@ -86,15 +86,15 @@ pub fn and(a: bool, b: bool) -> bool { a && b } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::or(true, false) * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::or(false, false) * false -* ~~~ +* ``` */ pub fn or(a: bool, b: bool) -> bool { a || b } @@ -105,15 +105,15 @@ pub fn or(a: bool, b: bool) -> bool { a || b } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::xor(true, false) * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::xor(true, true) * false -* ~~~ +* ``` */ pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) } @@ -126,15 +126,15 @@ pub fn xor(a: bool, b: bool) -> bool { (a && !b) || (!a && b) } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::implies(true, true) * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::implies(true, false) * false -* ~~~ +* ``` */ pub fn implies(a: bool, b: bool) -> bool { !a || b } @@ -143,15 +143,15 @@ pub fn implies(a: bool, b: bool) -> bool { !a || b } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::is_true(true) * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::is_true(false) * false -* ~~~ +* ``` */ pub fn is_true(v: bool) -> bool { v } @@ -160,15 +160,15 @@ pub fn is_true(v: bool) -> bool { v } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::is_false(false) * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::is_false(true) * false -* ~~~ +* ``` */ pub fn is_false(v: bool) -> bool { !v } @@ -179,20 +179,20 @@ pub fn is_false(v: bool) -> bool { !v } * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> FromStr::from_str::("true") * Some(true) -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> FromStr::from_str::("false") * Some(false) -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> FromStr::from_str::("not even a boolean") * None -* ~~~ +* ``` */ impl FromStr for bool { fn from_str(s: &str) -> Option { @@ -209,15 +209,15 @@ impl FromStr for bool { * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> true.to_str() * "true" -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> false.to_str() * "false" -* ~~~ +* ``` */ impl ToStr for bool { #[inline] @@ -232,11 +232,11 @@ impl ToStr for bool { * There are no guarantees about the order values will be given. * * # Examples -* ~~~ +* ``` * do std::bool::all_values |x: bool| { * println(x.to_str()) * } -* ~~~ +* ``` */ pub fn all_values(blk: &fn(v: bool)) { blk(true); @@ -248,15 +248,15 @@ pub fn all_values(blk: &fn(v: bool)) { * * # Examples * -* ~~~ {.rust} +* ```rust * rusti> std::bool::to_bit(true) * 1 -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> std::bool::to_bit(false) * 0 -* ~~~ +* ``` */ #[inline] pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } @@ -269,12 +269,12 @@ pub fn to_bit(v: bool) -> u8 { if v { 1u8 } else { 0u8 } } * ~~~rust * rusti> !true * false -* ~~~ +* ``` * * ~~~rust * rusti> !false * true -* ~~~ +* ``` */ #[cfg(not(test))] impl Not for bool { @@ -299,25 +299,25 @@ impl TotalOrd for bool { * * Two booleans are equal if they have the same value. * -* ~~~ {.rust} +* ```rust * rusti> false.eq(&true) * false -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> false == false * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> false != true * true -* ~~~ +* ``` * -* ~~~ {.rust} +* ```rust * rusti> false.ne(&false) * false -* ~~~ +* ``` */ #[cfg(not(test))] impl Eq for bool { diff --git a/src/libstd/c_str.rs b/src/libstd/c_str.rs index 3c50ff35358..823cc0db4b9 100644 --- a/src/libstd/c_str.rs +++ b/src/libstd/c_str.rs @@ -38,7 +38,7 @@ unnecessary amounts of allocations. An example of creating and using a C string would be: -~~~{.rust} +```rust use std::libc; externfn!(fn puts(s: *libc::c_char)) @@ -56,7 +56,7 @@ do my_c_string.with_ref |c_buffer| { do my_string.with_c_str |c_buffer| { unsafe { puts(c_buffer); } } -~~~ + ``` */ @@ -204,9 +204,9 @@ pub trait ToCStr { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let s = "PATH".with_c_str(|path| libc::getenv(path)) - /// ~~~ + /// ``` /// /// # Failure /// diff --git a/src/libstd/cast.rs b/src/libstd/cast.rs index a4e18d98f47..e028bbeac68 100644 --- a/src/libstd/cast.rs +++ b/src/libstd/cast.rs @@ -67,10 +67,10 @@ pub unsafe fn bump_box_refcount(t: @T) { forget(t); } * * # Example * - * ~~~ {.rust} + * ```rust * let v: &[u8] = transmute("L"); * assert!(v == [76u8]); - * ~~~ + * ``` */ #[inline] pub unsafe fn transmute(thing: L) -> G { diff --git a/src/libstd/condition.rs b/src/libstd/condition.rs index c47dcfe3de6..39db1df3df1 100644 --- a/src/libstd/condition.rs +++ b/src/libstd/condition.rs @@ -19,17 +19,17 @@ same manner. A condition is declared through the `condition!` macro provided by the compiler: -~~~{.rust} +```rust condition! { pub my_error: int -> ~str; } -~~~ + ``` This macro declares an inner module called `my_error` with one static variable, `cond` that is a static `Condition` instance. To help understand what the other parameters are used for, an example usage of this condition would be: -~~~{.rust} +```rust do my_error::cond.trap(|raised_int| { // the condition `my_error` was raised on, and the value it raised is stored @@ -51,7 +51,7 @@ do my_error::cond.trap(|raised_int| { println(my_error::cond.raise(4)); // prints "oh well" } -~~~ + ``` Condition handling is useful in cases where propagating errors is either to cumbersome or just not necessary in the first place. It should also be noted, @@ -96,14 +96,14 @@ impl Condition { /// /// # Example /// - /// ~~~{.rust} + /// ```rust /// condition! { my_error: int -> int; } /// /// let trap = my_error::cond.trap(|error| error + 3); /// /// // use `trap`'s inside method to register the handler and then run a /// // block of code with the handler registered - /// ~~~ + /// ``` pub fn trap<'a>(&'a self, h: &'a fn(T) -> U) -> Trap<'a, T, U> { let h: Closure = unsafe { ::cast::transmute(h) }; let prev = local_data::get(self.key, |k| k.map(|&x| *x)); @@ -173,14 +173,14 @@ impl<'self, T, U> Trap<'self, T, U> { /// /// # Example /// - /// ~~~{.rust} + /// ```rust /// condition! { my_error: int -> int; } /// /// let result = do my_error::cond.trap(|error| error + 3).inside { /// my_error::cond.raise(4) /// }; /// assert_eq!(result, 7); - /// ~~~ + /// ``` pub fn inside(&self, inner: &'self fn() -> V) -> V { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS"); diff --git a/src/libstd/fmt/mod.rs b/src/libstd/fmt/mod.rs index 99a5ed4d698..f35a61677e8 100644 --- a/src/libstd/fmt/mod.rs +++ b/src/libstd/fmt/mod.rs @@ -33,14 +33,14 @@ arguments directly while performing minimal allocations. Some examples of the `format!` extension are: -~~~{.rust} +```rust format!("Hello") // => ~"Hello" format!("Hello, {:s}!", "world") // => ~"Hello, world!" format!("The number is {:d}", 1) // => ~"The number is 1" format!("{:?}", ~[3, 4]) // => ~"~[3, 4]" format!("{value}", value=4) // => ~"4" format!("{} {}", 1, 2) // => ~"1 2" -~~~ + ``` From these, you can see that the first argument is a format string. It is required by the compiler for this to be a string literal; it cannot be a @@ -67,9 +67,9 @@ function, but the `format!` macro is a syntax extension which allows it to leverage named parameters. Named parameters are listed at the end of the argument list and have the syntax: -~~~ + ``` identifier '=' expression -~~~ + ``` It is illegal to put positional parameters (those without names) after arguments which have names. Like positional parameters, it is illegal to provided named @@ -84,9 +84,9 @@ and if all references to one argument do not provide a type, then the format `?` is used (the type's rust-representation is printed). For example, this is an invalid format string: -~~~ + ``` {0:d} {0:s} -~~~ + ``` Because the first argument is both referred to as an integer as well as a string. @@ -100,9 +100,9 @@ must have the type `uint`. Although a `uint` can be printed with `{:u}`, it is illegal to reference an argument as such. For example, this is another invalid format string: -~~~ + ``` {:.*s} {0:u} -~~~ + ``` ### Formatting traits @@ -134,9 +134,9 @@ is `?` which is defined for all types by default. When implementing a format trait for your own time, you will have to implement a method of the signature: -~~~{.rust} +```rust fn fmt(value: &T, f: &mut std::fmt::Formatter); -~~~ + ``` Your type will be passed by-reference in `value`, and then the function should emit output into the `f.buf` stream. It is up to each format trait @@ -150,14 +150,14 @@ helper methods. There are a number of related macros in the `format!` family. The ones that are currently implemented are: -~~~{.rust} +```rust format! // described above write! // first argument is a &mut rt::io::Writer, the destination writeln! // same as write but appends a newline print! // the format string is printed to the standard output println! // same as print but appends a newline format_args! // described below. -~~~ + ``` #### `write!` @@ -167,12 +167,12 @@ specified stream. This is used to prevent intermediate allocations of format strings and instead directly write the output. Under the hood, this function is actually invoking the `write` function defined in this module. Example usage is: -~~~{.rust} +```rust use std::rt::io; let mut w = io::mem::MemWriter::new(); write!(&mut w as &mut io::Writer, "Hello {}!", "world"); -~~~ + ``` #### `print!` @@ -180,10 +180,10 @@ This and `println` emit their output to stdout. Similarly to the `write!` macro, the goal of these macros is to avoid intermediate allocations when printing output. Example usage is: -~~~{.rust} +```rust print!("Hello {}!", "world"); println!("I have a newline {}", "character at the end"); -~~~ + ``` #### `format_args!` This is a curious macro which is used to safely pass around @@ -193,13 +193,13 @@ references information on the stack. Under the hood, all of the related macros are implemented in terms of this. First off, some example usage is: -~~~{.rust} +```rust use std::fmt; format_args!(fmt::format, "this returns {}", "~str"); format_args!(|args| { fmt::write(my_writer, args) }, "some {}", "args"); format_args!(my_fn, "format {}", "string"); -~~~ + ``` The first argument of the `format_args!` macro is a function (or closure) which takes one argument of type `&fmt::Arguments`. This structure can then be @@ -236,9 +236,9 @@ Furthermore, whenever a case is running, the special character `#` can be used to reference the string value of the argument which was selected upon. As an example: -~~~{.rust} +```rust format!("{0, select, other{#}}", "hello") // => ~"hello" -~~~ + ``` This example is the equivalent of `{0:s}` essentially. @@ -247,9 +247,9 @@ This example is the equivalent of `{0:s}` essentially. The select method is a switch over a `&str` parameter, and the parameter *must* be of the type `&str`. An example of the syntax is: -~~~ + ``` {0, select, male{...} female{...} other{...}} -~~~ + ``` Breaking this down, the `0`-th argument is selected upon with the `select` method, and then a number of cases follow. Each case is preceded by an @@ -266,9 +266,9 @@ The plural method is a switch statement over a `uint` parameter, and the parameter *must* be a `uint`. A plural method in its full glory can be specified as: -~~~ + ``` {0, plural, offset=1 =1{...} two{...} many{...} other{...}} -~~~ + ``` To break this down, the first `0` indicates that this method is selecting over the value of the first positional parameter to the format string. Next, the @@ -294,7 +294,7 @@ should not be too alien. Arguments are formatted with python-like syntax, meaning that arguments are surrounded by `{}` instead of the C-like `%`. The actual grammar for the formatting syntax is: -~~~ + ``` format_string := [ format ] * format := '{' [ argument ] [ ':' format_spec ] [ ',' function_spec ] '}' argument := integer | identifier @@ -315,7 +315,7 @@ plural := 'plural' ',' [ 'offset:' integer ] ( selector arm ) * selector := '=' integer | keyword keyword := 'zero' | 'one' | 'two' | 'few' | 'many' | 'other' arm := '{' format_string '}' -~~~ + ``` ## Formatting Parameters @@ -516,11 +516,11 @@ pub trait Float { fn fmt(&Self, &mut Formatter); } /// /// # Example /// -/// ~~~{.rust} +/// ```rust /// use std::fmt; /// let w: &mut io::Writer = ...; /// format_args!(|args| { fmt::write(w, args) }, "Hello, {}!", "world"); -/// ~~~ +/// ``` pub fn write(output: &mut io::Writer, args: &Arguments) { unsafe { write_unsafe(output, args.fmt, args.args) } } @@ -581,11 +581,11 @@ pub unsafe fn write_unsafe(output: &mut io::Writer, /// /// # Example /// -/// ~~~{.rust} +/// ```rust /// use std::fmt; /// let s = format_args!(fmt::format, "Hello, {}!", "world"); /// assert_eq!(s, "Hello, world!"); -/// ~~~ +/// ``` pub fn format(args: &Arguments) -> ~str { unsafe { format_unsafe(args.fmt, args.args) } } diff --git a/src/libstd/io.rs b/src/libstd/io.rs index ab8af22e116..859cf20fa41 100644 --- a/src/libstd/io.rs +++ b/src/libstd/io.rs @@ -1047,11 +1047,11 @@ pub fn FILE_reader(f: *libc::FILE, cleanup: bool) -> @Reader { * * # Example * -* ~~~ {.rust} +* ```rust * let stdin = std::io::stdin(); * let line = stdin.read_line(); * std::io::print(line); -* ~~~ +* ``` */ pub fn stdin() -> @Reader { #[fixed_stack_segment]; #[inline(never)]; @@ -1650,10 +1650,10 @@ pub fn buffered_file_writer(path: &Path) -> Result<@Writer, ~str> { * * # Example * -* ~~~ {.rust} +* ```rust * let stdout = std::io::stdout(); * stdout.write_str("hello\n"); -* ~~~ +* ``` */ pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) } @@ -1662,10 +1662,10 @@ pub fn stdout() -> @Writer { fd_writer(libc::STDOUT_FILENO as c_int, false) } * * # Example * -* ~~~ {.rust} +* ```rust * let stderr = std::io::stderr(); * stderr.write_str("hello\n"); -* ~~~ +* ``` */ pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) } @@ -1677,10 +1677,10 @@ pub fn stderr() -> @Writer { fd_writer(libc::STDERR_FILENO as c_int, false) } * * # Example * -* ~~~ {.rust} +* ```rust * // print is imported into the prelude, and so is always available. * print("hello"); -* ~~~ +* ``` */ pub fn print(s: &str) { stdout().write_str(s); @@ -1693,10 +1693,10 @@ pub fn print(s: &str) { * * # Example * -* ~~~ {.rust} +* ```rust * // println is imported into the prelude, and so is always available. * println("hello"); -* ~~~ +* ``` */ pub fn println(s: &str) { stdout().write_line(s); diff --git a/src/libstd/iter.rs b/src/libstd/iter.rs index 87fad9aae70..0e4cb895249 100644 --- a/src/libstd/iter.rs +++ b/src/libstd/iter.rs @@ -34,7 +34,7 @@ trait defined in this module. For loops can be viewed as a syntactical expansion into a `loop`, for example, the `for` loop in this example is essentially translated to the `loop` below. -~~~{.rust} +```rust let values = ~[1, 2, 3]; // "Syntactical sugar" taking advantage of an iterator @@ -52,7 +52,7 @@ loop { None => { break } } } -~~~ + ``` This `for` loop syntax can be applied to any iterator over any type. @@ -111,14 +111,14 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().chain(b.iter()); /// assert_eq!(it.next().get(), &0); /// assert_eq!(it.next().get(), &1); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn chain>(self, other: U) -> Chain { Chain{a: self, b: other, flag: false} @@ -131,13 +131,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [0]; /// let b = [1]; /// let mut it = a.iter().zip(b.iter()); /// assert_eq!(it.next().get(), (&0, &1)); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn zip>(self, other: U) -> Zip { Zip{a: self, b: other} @@ -148,13 +148,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().map(|&x| 2 * x); /// assert_eq!(it.next().get(), 2); /// assert_eq!(it.next().get(), 4); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn map<'r, B>(self, f: &'r fn(A) -> B) -> Map<'r, A, B, Self> { Map{iter: self, f: f} @@ -166,12 +166,12 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().filter(|&x| *x > 1); /// assert_eq!(it.next().get(), &2); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn filter<'r>(self, predicate: &'r fn(&A) -> bool) -> Filter<'r, A, Self> { Filter{iter: self, predicate: predicate} @@ -183,12 +183,12 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2]; /// let mut it = a.iter().filter_map(|&x| if x > 1 {Some(2 * x)} else {None}); /// assert_eq!(it.next().get(), 4); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn filter_map<'r, B>(self, f: &'r fn(A) -> Option) -> FilterMap<'r, A, B, Self> { FilterMap { iter: self, f: f } @@ -199,13 +199,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [100, 200]; /// let mut it = a.iter().enumerate(); /// assert_eq!(it.next().get(), (0, &100)); /// assert_eq!(it.next().get(), (1, &200)); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn enumerate(self) -> Enumerate { Enumerate{iter: self, count: 0} @@ -217,7 +217,7 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [100, 200, 300]; /// let mut it = xs.iter().map(|&x|x).peekable(); /// assert_eq!(it.peek().unwrap(), &100); @@ -228,7 +228,7 @@ pub trait Iterator { /// assert_eq!(it.next().unwrap(), 300); /// assert!(it.peek().is_none()); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn peekable(self) -> Peekable { Peekable{iter: self, peeked: None} @@ -240,14 +240,14 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 2, 1]; /// let mut it = a.iter().skip_while(|&a| *a < 3); /// assert_eq!(it.next().get(), &3); /// assert_eq!(it.next().get(), &2); /// assert_eq!(it.next().get(), &1); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn skip_while<'r>(self, predicate: &'r fn(&A) -> bool) -> SkipWhile<'r, A, Self> { SkipWhile{iter: self, flag: false, predicate: predicate} @@ -259,13 +259,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 2, 1]; /// let mut it = a.iter().take_while(|&a| *a < 3); /// assert_eq!(it.next().get(), &1); /// assert_eq!(it.next().get(), &2); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn take_while<'r>(self, predicate: &'r fn(&A) -> bool) -> TakeWhile<'r, A, Self> { TakeWhile{iter: self, flag: false, predicate: predicate} @@ -276,13 +276,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().skip(3); /// assert_eq!(it.next().get(), &4); /// assert_eq!(it.next().get(), &5); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn skip(self, n: uint) -> Skip { Skip{iter: self, n: n} @@ -293,14 +293,14 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().take(3); /// assert_eq!(it.next().get(), &1); /// assert_eq!(it.next().get(), &2); /// assert_eq!(it.next().get(), &3); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn take(self, n: uint) -> Take { Take{iter: self, n: n} @@ -313,7 +313,7 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().scan(1, |fac, &x| { /// *fac = *fac * x; @@ -325,7 +325,7 @@ pub trait Iterator { /// assert_eq!(it.next().get(), 24); /// assert_eq!(it.next().get(), 120); /// assert!(it.next().is_none()); - /// ~~~ + /// ``` #[inline] fn scan<'r, St, B>(self, initial_state: St, f: &'r fn(&mut St, A) -> Option) -> Scan<'r, A, B, Self, St> { @@ -337,7 +337,7 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let xs = [2u, 3]; /// let ys = [0u, 1, 0, 1, 2]; /// let mut it = xs.iter().flat_map(|&x| count(0u, 1).take(x)); @@ -347,7 +347,7 @@ pub trait Iterator { /// assert_eq!(x, ys[i]); /// i += 1; /// } - /// ~~~ + /// ``` #[inline] fn flat_map<'r, B, U: Iterator>(self, f: &'r fn(A) -> U) -> FlatMap<'r, A, Self, U> { @@ -360,7 +360,7 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// fn process>(it: U) -> int { /// let mut it = it.fuse(); /// let mut sum = 0; @@ -378,7 +378,7 @@ pub trait Iterator { /// } /// let x = ~[1,2,3,7,8,9]; /// assert_eq!(process(x.move_iter()), 1006); - /// ~~~ + /// ``` #[inline] fn fuse(self) -> Fuse { Fuse{iter: self, done: false} @@ -390,7 +390,7 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust ///let xs = [1u, 4, 2, 3, 8, 9, 6]; ///let sum = xs.iter() /// .map(|&x| x) @@ -399,7 +399,7 @@ pub trait Iterator { /// .inspect(|&x| debug!("%u made it through", x)) /// .sum(); ///println(sum.to_str()); - /// ~~~ + /// ``` #[inline] fn inspect<'r>(self, f: &'r fn(&A)) -> Inspect<'r, A, Self> { Inspect{iter: self, f: f} @@ -409,13 +409,13 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::iter::count; /// /// for i in count(0, 10) { /// printfln!("%d", i); /// } - /// ~~~ + /// ``` #[inline] fn advance(&mut self, f: &fn(A) -> bool) -> bool { loop { @@ -433,11 +433,11 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let b: ~[int] = a.iter().map(|&x| x).collect(); /// assert!(a == b); - /// ~~~ + /// ``` #[inline] fn collect>(&mut self) -> B { FromIterator::from_iterator(self) @@ -448,11 +448,11 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let b: ~[int] = a.iter().map(|&x| x).to_owned_vec(); /// assert!(a == b); - /// ~~~ + /// ``` #[inline] fn to_owned_vec(&mut self) -> ~[A] { self.collect() @@ -463,12 +463,12 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.nth(2).get() == &3); /// assert!(it.nth(2) == None); - /// ~~~ + /// ``` #[inline] fn nth(&mut self, mut n: uint) -> Option { loop { @@ -485,10 +485,10 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().last().get() == &5); - /// ~~~ + /// ``` #[inline] fn last(&mut self) -> Option { let mut last = None; @@ -501,10 +501,10 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().fold(0, |a, &b| a + b) == 15); - /// ~~~ + /// ``` #[inline] fn fold(&mut self, init: B, f: &fn(B, A) -> B) -> B { let mut accum = init; @@ -521,12 +521,12 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.len() == 5); /// assert!(it.len() == 0); - /// ~~~ + /// ``` #[inline] fn len(&mut self) -> uint { self.fold(0, |cnt, _x| cnt + 1) @@ -536,11 +536,11 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().all(|&x| *x > 0)); /// assert!(!a.iter().all(|&x| *x > 2)); - /// ~~~ + /// ``` #[inline] fn all(&mut self, f: &fn(A) -> bool) -> bool { for x in *self { if !f(x) { return false; } } @@ -552,12 +552,12 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); /// assert!(it.any(|&x| *x == 3)); /// assert!(!it.any(|&x| *x == 3)); - /// ~~~ + /// ``` #[inline] fn any(&mut self, f: &fn(A) -> bool) -> bool { for x in *self { if f(x) { return true; } } @@ -601,10 +601,10 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let xs = [-3, 0, 1, 5, -10]; /// assert_eq!(*xs.iter().max_by(|x| x.abs()).unwrap(), -10); - /// ~~~ + /// ``` #[inline] fn max_by(&mut self, f: &fn(&A) -> B) -> Option { self.fold(None, |max: Option<(A, B)>, x| { @@ -625,10 +625,10 @@ pub trait Iterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let xs = [-3, 0, 1, 5, -10]; /// assert_eq!(*xs.iter().min_by(|x| x.abs()).unwrap(), 0); - /// ~~~ + /// ``` #[inline] fn min_by(&mut self, f: &fn(&A) -> B) -> Option { self.fold(None, |min: Option<(A, B)>, x| { @@ -777,11 +777,11 @@ pub trait AdditiveIterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter().map(|&x| x); /// assert!(it.sum() == 15); - /// ~~~ + /// ``` fn sum(&mut self) -> A; } @@ -800,7 +800,7 @@ pub trait MultiplicativeIterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::iter::count; /// /// fn factorial(n: uint) -> uint { @@ -809,7 +809,7 @@ pub trait MultiplicativeIterator { /// assert!(factorial(0) == 1); /// assert!(factorial(1) == 1); /// assert!(factorial(5) == 120); - /// ~~~ + /// ``` fn product(&mut self) -> A; } @@ -828,20 +828,20 @@ pub trait OrdIterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().max().get() == &5); - /// ~~~ + /// ``` fn max(&mut self) -> Option; /// Consumes the entire iterator to return the minimum element. /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = [1, 2, 3, 4, 5]; /// assert!(a.iter().min().get() == &1); - /// ~~~ + /// ``` fn min(&mut self) -> Option; } @@ -873,12 +873,12 @@ pub trait ClonableIterator { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let a = count(1,1).take(1); /// let mut cy = a.cycle(); /// assert_eq!(cy.next(), Some(1)); /// assert_eq!(cy.next(), Some(1)); - /// ~~~ + /// ``` fn cycle(self) -> Cycle; } diff --git a/src/libstd/local_data.rs b/src/libstd/local_data.rs index 9c4e5ba60df..5058821d456 100644 --- a/src/libstd/local_data.rs +++ b/src/libstd/local_data.rs @@ -22,7 +22,7 @@ To declare a new key for storing local data of a particular type, use the named and annotated. This name is then passed to the functions in this module to modify/read the slot specified by the key. -~~~{.rust} +```rust use std::local_data; local_data_key!(key_int: int) @@ -33,7 +33,7 @@ local_data::get(key_int, |opt| assert_eq!(opt, Some(&3))); local_data::set(key_vector, ~[4]); local_data::get(key_vector, |opt| assert_eq!(opt, Some(&~[4]))); -~~~ + ``` */ diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index a2a0a1ab13b..afa1acd0897 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -346,9 +346,9 @@ impl Round for f32 { /// /// The fractional part of the number, satisfying: /// - /// ~~~ {.rust} + /// ```rust /// assert!(x == trunc(x) + fract(x)) - /// ~~~ + /// ``` /// #[inline] fn fract(&self) -> f32 { *self - self.trunc() } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index f7c31c40250..5dbeb6c298f 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -364,9 +364,9 @@ impl Round for f64 { /// /// The fractional part of the number, satisfying: /// - /// ~~~ {.rust} + /// ```rust /// assert!(x == trunc(x) + fract(x)) - /// ~~~ + /// ``` /// #[inline] fn fract(&self) -> f64 { *self - self.trunc() } diff --git a/src/libstd/num/float.rs b/src/libstd/num/float.rs index dc46d4fec32..7af47355c8c 100644 --- a/src/libstd/num/float.rs +++ b/src/libstd/num/float.rs @@ -414,9 +414,9 @@ impl Round for float { /// /// The fractional part of the number, satisfying: /// - /// ~~~ {.rust} + /// ```rust /// assert!(x == trunc(x) + fract(x)) - /// ~~~ + /// ``` /// #[inline] fn fract(&self) -> float { *self - self.trunc() } diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index ba8beeba4f6..1070e8e592f 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -118,7 +118,7 @@ impl Div<$T,$T> for $T { /// /// # Examples /// - /// ~~~ + /// ``` /// assert!( 8 / 3 == 2); /// assert!( 8 / -3 == -2); /// assert!(-8 / 3 == -2); @@ -128,7 +128,7 @@ impl Div<$T,$T> for $T { /// assert!( 1 / -2 == 0); /// assert!(-1 / 2 == 0); /// assert!(-1 / -2 == 0); - /// ~~~ + /// ``` /// #[inline] fn div(&self, other: &$T) -> $T { *self / *other } @@ -139,13 +139,13 @@ impl Rem<$T,$T> for $T { /// /// Returns the integer remainder after division, satisfying: /// - /// ~~~ + /// ``` /// assert!((n / d) * d + (n % d) == n) - /// ~~~ + /// ``` /// /// # Examples /// - /// ~~~ + /// ``` /// assert!( 8 % 3 == 2); /// assert!( 8 % -3 == 2); /// assert!(-8 % 3 == -2); @@ -155,7 +155,7 @@ impl Rem<$T,$T> for $T { /// assert!( 1 % -2 == 1); /// assert!(-1 % 2 == -1); /// assert!(-1 % -2 == -1); - /// ~~~ + /// ``` /// #[inline] fn rem(&self, other: &$T) -> $T { *self % *other } @@ -214,7 +214,7 @@ impl Integer for $T { /// /// # Examples /// - /// ~~~ + /// ``` /// assert!(( 8).div_floor( 3) == 2); /// assert!(( 8).div_floor(-3) == -3); /// assert!((-8).div_floor( 3) == -3); @@ -224,7 +224,7 @@ impl Integer for $T { /// assert!(( 1).div_floor(-2) == -1); /// assert!((-1).div_floor( 2) == -1); /// assert!((-1).div_floor(-2) == 0); - /// ~~~ + /// ``` /// #[inline] fn div_floor(&self, other: &$T) -> $T { @@ -240,13 +240,13 @@ impl Integer for $T { /// /// Integer modulo, satisfying: /// - /// ~~~ + /// ``` /// assert!(n.div_floor(d) * d + n.mod_floor(d) == n) - /// ~~~ + /// ``` /// /// # Examples /// - /// ~~~ + /// ``` /// assert!(( 8).mod_floor( 3) == 2); /// assert!(( 8).mod_floor(-3) == -1); /// assert!((-8).mod_floor( 3) == 1); @@ -256,7 +256,7 @@ impl Integer for $T { /// assert!(( 1).mod_floor(-2) == -1); /// assert!((-1).mod_floor( 2) == 1); /// assert!((-1).mod_floor(-2) == -1); - /// ~~~ + /// ``` /// #[inline] fn mod_floor(&self, other: &$T) -> $T { diff --git a/src/libstd/num/num.rs b/src/libstd/num/num.rs index 634c86104fb..a60bf2f33a9 100644 --- a/src/libstd/num/num.rs +++ b/src/libstd/num/num.rs @@ -82,12 +82,12 @@ pub trait Unsigned: Num {} /// Times trait /// -/// ~~~ {.rust} +/// ```rust /// use num::Times; /// let ten = 10 as uint; /// let mut accum = 0; /// do ten.times { accum += 1; } -/// ~~~ +/// ``` /// pub trait Times { fn times(&self, it: &fn()); @@ -357,10 +357,10 @@ pub trait Float: Real /// /// # Example /// -/// ~~~ +/// ``` /// let twenty: f32 = num::cast(0x14); /// assert_eq!(twenty, 20f32); -/// ~~~ +/// ``` /// #[inline] pub fn cast(n: T) -> U { diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 37c5807c70b..a8d4cf541ce 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -23,7 +23,7 @@ of a value and take action, always accounting for the `None` case. # Example -~~~ + ``` let msg = Some(~"howdy"); // Take a reference to the contained string @@ -37,7 +37,7 @@ let unwrapped_msg = match msg { Some(m) => m, None => ~"default message" }; -~~~ + ``` */ diff --git a/src/libstd/rand/distributions.rs b/src/libstd/rand/distributions.rs index 6d08b3c84bd..1cdf4d6da95 100644 --- a/src/libstd/rand/distributions.rs +++ b/src/libstd/rand/distributions.rs @@ -65,14 +65,14 @@ fn ziggurat(rng: &mut R, /// /// # Example /// -/// ~~~ +/// ``` /// use std::rand::distributions::StandardNormal; /// /// fn main() { /// let normal = 2.0 + (*rand::random::()) * 3.0; /// printfln!("%f is from a N(2, 9) distribution", normal) /// } -/// ~~~ +/// ``` pub struct StandardNormal(f64); impl Rand for StandardNormal { @@ -119,14 +119,14 @@ impl Rand for StandardNormal { /// /// # Example /// -/// ~~~ +/// ``` /// use std::rand::distributions::Exp1; /// /// fn main() { /// let exp2 = (*rand::random::()) * 0.5; /// printfln!("%f is from a Exp(2) distribution", exp2); /// } -/// ~~~ +/// ``` pub struct Exp1(f64); // This could be done via `-rng.gen::().ln()` but that is slower. diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 7b753f821d7..832978a0f10 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -21,7 +21,7 @@ distributions like normal and exponential. # Examples -~~~ {.rust} +```rust use std::rand; use std::rand::Rng; @@ -31,16 +31,16 @@ fn main() { printfln!("int: %d, uint: %u", rng.gen(), rng.gen()) } } -~~~ + ``` -~~~ {.rust} +```rust use std::rand; fn main () { let tuple_ptr = rand::random::<~(f64, char)>(); printfln!(tuple_ptr) } -~~~ + ``` */ use cast; @@ -264,7 +264,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { @@ -273,7 +273,7 @@ pub trait Rng { /// printfln!(x); /// printfln!(rng.gen::<(float, bool)>()); /// } - /// ~~~ + /// ``` #[inline(always)] fn gen(&mut self) -> T { Rand::rand(self) @@ -283,7 +283,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { @@ -292,7 +292,7 @@ pub trait Rng { /// printfln!(x); /// printfln!(rng.gen_vec::<(float, bool)>(5)); /// } - /// ~~~ + /// ``` fn gen_vec(&mut self, len: uint) -> ~[T] { vec::from_fn(len, |_| self.gen()) } @@ -308,7 +308,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { @@ -318,7 +318,7 @@ pub trait Rng { /// let m: i16 = rng.gen_integer_range(-40, 400); /// printfln!(m); /// } - /// ~~~ + /// ``` fn gen_integer_range(&mut self, low: T, high: T) -> T { assert!(low < high, "RNG.gen_integer_range called with low >= high"); let range = (high - low).to_u64(); @@ -335,7 +335,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// use std::rand::Rng; /// @@ -343,7 +343,7 @@ pub trait Rng { /// let mut rng = rand::rng(); /// printfln!("%b", rng.gen_weighted_bool(3)); /// } - /// ~~~ + /// ``` fn gen_weighted_bool(&mut self, n: uint) -> bool { n == 0 || self.gen_integer_range(0, n) == 0 } @@ -353,13 +353,13 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { /// println(rand::task_rng().gen_ascii_str(10)); /// } - /// ~~~ + /// ``` fn gen_ascii_str(&mut self, len: uint) -> ~str { static GEN_ASCII_STR_CHARSET: &'static [u8] = bytes!("ABCDEFGHIJKLMNOPQRSTUVWXYZ\ abcdefghijklmnopqrstuvwxyz\ @@ -381,14 +381,14 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { /// printfln!(rand::task_rng().choose_option([1,2,4,8,16,32])); /// printfln!(rand::task_rng().choose_option([])); /// } - /// ~~~ + /// ``` fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { if values.is_empty() { None @@ -402,7 +402,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// use std::rand::Rng; /// @@ -413,7 +413,7 @@ pub trait Rng { /// rand::Weighted {weight: 2, item: 'c'}]; /// printfln!("%c", rng.choose_weighted(x)); /// } - /// ~~~ + /// ``` fn choose_weighted(&mut self, v: &[Weighted]) -> T { self.choose_weighted_option(v).expect("Rng.choose_weighted: total weight is 0") } @@ -423,7 +423,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// use std::rand::Rng; /// @@ -434,7 +434,7 @@ pub trait Rng { /// rand::Weighted {weight: 2, item: 'c'}]; /// printfln!(rng.choose_weighted_option(x)); /// } - /// ~~~ + /// ``` fn choose_weighted_option(&mut self, v: &[Weighted]) -> Option { let mut total = 0u; @@ -460,7 +460,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// use std::rand::Rng; /// @@ -471,7 +471,7 @@ pub trait Rng { /// rand::Weighted {weight: 2, item: 'c'}]; /// printfln!(rng.weighted_vec(x)); /// } - /// ~~~ + /// ``` fn weighted_vec(&mut self, v: &[Weighted]) -> ~[T] { let mut r = ~[]; for item in v.iter() { @@ -486,13 +486,13 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { /// printfln!(rand::task_rng().shuffle(~[1,2,3])); /// } - /// ~~~ + /// ``` fn shuffle(&mut self, values: ~[T]) -> ~[T] { let mut v = values; self.shuffle_mut(v); @@ -503,7 +503,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { @@ -514,7 +514,7 @@ pub trait Rng { /// rng.shuffle_mut(y); /// printfln!(y); /// } - /// ~~~ + /// ``` fn shuffle_mut(&mut self, values: &mut [T]) { let mut i = values.len(); while i >= 2u { @@ -529,7 +529,7 @@ pub trait Rng { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// use std::rand; /// /// fn main() { @@ -537,7 +537,7 @@ pub trait Rng { /// let sample = rng.sample(range(1, 100), 5); /// printfln!(sample); /// } - /// ~~~ + /// ``` fn sample>(&mut self, iter: T, n: uint) -> ~[A] { let mut reservoir : ~[A] = vec::with_capacity(n); for (i, elem) in iter.enumerate() { diff --git a/src/libstd/rt/io/buffered.rs b/src/libstd/rt/io/buffered.rs index 7988f640687..3e801f28991 100644 --- a/src/libstd/rt/io/buffered.rs +++ b/src/libstd/rt/io/buffered.rs @@ -17,7 +17,7 @@ //! //! # Examples //! -//! ~~~ +//! ``` //! let tcp_stream = TcpStream::connect(addr); //! let reader = BufferedReader::new(tcp_stream); //! @@ -26,17 +26,17 @@ //! Some(nread) => println!("Read {} bytes", nread), //! None => println!("At the end of the stream!") //! } -//! ~~~ +//! ``` //! -//! ~~~ +//! ``` //! let tcp_stream = TcpStream::connect(addr); //! let writer = BufferedWriter::new(tcp_stream); //! //! writer.write("hello, world".as_bytes()); //! writer.flush(); -//! ~~~ +//! ``` //! -//! ~~~ +//! ``` //! let tcp_stream = TcpStream::connect(addr); //! let stream = BufferedStream::new(tcp_stream); //! @@ -48,7 +48,7 @@ //! Some(nread) => println!("Read {} bytes", nread), //! None => println!("At the end of the stream!") //! } -//! ~~~ +//! ``` //! use prelude::*; diff --git a/src/libstd/rt/io/file.rs b/src/libstd/rt/io/file.rs index 2206f8bf6ae..b11ee014af9 100644 --- a/src/libstd/rt/io/file.rs +++ b/src/libstd/rt/io/file.rs @@ -477,7 +477,7 @@ pub trait FileSystemInfo { /// /// * Check if a file exists, reading from it if so /// -/// ~~~{.rust} +/// ```rust /// use std; /// use std::path::Path; /// use std::rt::io::file::{FileInfo, FileReader}; @@ -489,17 +489,17 @@ pub trait FileSystemInfo { /// reader.read(mem); /// // ... /// } -/// ~~~ +/// ``` /// /// * Is the given path a file? /// -/// ~~~{.rust} +/// ```rust /// let f = get_file_path_from_wherever(); /// match f.is_file() { /// true => doing_something_with_a_file(f), /// _ => {} /// } -/// ~~~ +/// ``` pub trait FileInfo : FileSystemInfo { /// Whether the underlying implemention (be it a file path, /// or something else) points at a "regular file" on the FS. Will return @@ -574,7 +574,7 @@ impl FileInfo for Path { } /// /// * Check if a directory exists, `mkdir`'ing it if not /// -/// ~~~{.rust} +/// ```rust /// use std; /// use std::path::Path; /// use std::rt::io::file::{DirectoryInfo}; @@ -583,11 +583,11 @@ impl FileInfo for Path { } /// if !dir.exists() { /// dir.mkdir(); /// } -/// ~~~ +/// ``` /// /// * Is the given path a directory? If so, iterate on its contents /// -/// ~~~{.rust} +/// ```rust /// fn visit_dirs(dir: &Path, cb: &fn(&Path)) { /// if dir.is_dir() { /// let contents = dir.readdir(); @@ -598,7 +598,7 @@ impl FileInfo for Path { } /// } /// else { fail!("nope"); } /// } -/// ~~~ +/// ``` trait DirectoryInfo : FileSystemInfo { /// Whether the underlying implemention (be it a file path, /// or something else) is pointing at a directory in the underlying FS. @@ -971,4 +971,4 @@ mod test { dir.rmdir(); } } -} \ No newline at end of file +} diff --git a/src/libstd/rt/io/mock.rs b/src/libstd/rt/io/mock.rs index b580b752bd9..c46e1372c64 100644 --- a/src/libstd/rt/io/mock.rs +++ b/src/libstd/rt/io/mock.rs @@ -47,4 +47,4 @@ impl MockWriter { impl Writer for MockWriter { fn write(&mut self, buf: &[u8]) { (self.write)(buf) } fn flush(&mut self) { (self.flush)() } -} \ No newline at end of file +} diff --git a/src/libstd/rt/kill.rs b/src/libstd/rt/kill.rs index 92dc62490ed..6563ac2e96f 100644 --- a/src/libstd/rt/kill.rs +++ b/src/libstd/rt/kill.rs @@ -71,14 +71,14 @@ before reporting whether it succeeded or failed. A watching parent will only report success if it succeeded and all its children also reported success; otherwise, it will report failure. This is most useful for writing test cases: -~~~ + ``` #[test] fn test_something_in_another_task { do spawn { assert!(collatz_conjecture_is_false()); } } -~~~ + ``` Here, as the child task will certainly outlive the parent task, we might miss the failure of the child when deciding whether or not the test case passed. diff --git a/src/libstd/str.rs b/src/libstd/str.rs index c94d8f366a6..8dc6f783fbe 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -37,13 +37,13 @@ there are three common kinds of strings in rust: As an example, here's a few different kinds of strings. -~~~{.rust} +```rust let owned_string = ~"I am an owned string"; let managed_string = @"This string is garbage-collected"; let borrowed_string1 = "This string is borrowed with the 'static lifetime"; let borrowed_string2: &str = owned_string; // owned strings can be borrowed let borrowed_string3: &str = managed_string; // managed strings can also be borrowed -~~~ + ``` From the example above, you can see that rust has 3 different kinds of string literals. The owned/managed literals correspond to the owned/managed string @@ -67,12 +67,12 @@ to that string. With these guarantees, strings can easily transition between being mutable/immutable with the same benefits of having mutable strings in other languages. -~~~{.rust} +```rust let mut buf = ~"testing"; buf.push_char(' '); buf.push_str("123"); assert_eq!(buf, ~"testing 123"); -~~~ + ``` # Representation @@ -1513,10 +1513,10 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let v: ~[char] = "abc åäö".iter().collect(); /// assert_eq!(v, ~['a', 'b', 'c', ' ', 'å', 'ä', 'ö']); - /// ~~~ + /// ``` #[inline] fn iter(&self) -> CharIterator<'self> { CharIterator{string: *self} @@ -1558,13 +1558,13 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let v: ~[&str] = "Mary had a little lamb".split_iter(' ').collect(); /// assert_eq!(v, ~["Mary", "had", "a", "little", "lamb"]); /// /// let v: ~[&str] = "abc1def2ghi".split_iter(|c: char| c.is_digit()).collect(); /// assert_eq!(v, ~["abc", "def", "ghi"]); - /// ~~~ + /// ``` #[inline] fn split_iter(&self, sep: Sep) -> CharSplitIterator<'self, Sep> { CharSplitIterator { @@ -1597,10 +1597,10 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let v: ~[&str] = "A.B.".split_terminator_iter('.').collect(); /// assert_eq!(v, ~["A", "B"]); - /// ~~~ + /// ``` #[inline] fn split_terminator_iter(&self, sep: Sep) -> CharSplitIterator<'self, Sep> { @@ -1615,10 +1615,10 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let v: ~[&str] = "Mary had a little lamb".rsplit_iter(' ').collect(); /// assert_eq!(v, ~["lamb", "little", "a", "had", "Mary"]); - /// ~~~ + /// ``` #[inline] fn rsplit_iter(&self, sep: Sep) -> CharRSplitIterator<'self, Sep> { self.split_iter(sep).invert() @@ -1655,10 +1655,10 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let v: ~[&str] = "abcXXXabcYYYabc".split_str_iter("abc").collect() /// assert_eq!(v, ["", "XXX", "YYY", ""]); - /// ~~~ + /// ``` #[inline] fn split_str_iter(&self, sep: &'self str) -> StrSplitIterator<'self> { StrSplitIterator { @@ -1853,11 +1853,11 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// assert_eq!("11foo1bar11".trim_chars(&'1'), "foo1bar") /// assert_eq!("12foo1bar12".trim_chars(& &['1', '2']), "foo1bar") /// assert_eq!("123foo1bar123".trim_chars(&|c: char| c.is_digit()), "foo1bar") - /// ~~~ + /// ``` #[inline] fn trim_chars(&self, to_trim: &C) -> &'self str { self.trim_left_chars(to_trim).trim_right_chars(to_trim) @@ -1871,11 +1871,11 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// assert_eq!("11foo1bar11".trim_left_chars(&'1'), "foo1bar11") /// assert_eq!("12foo1bar12".trim_left_chars(& &['1', '2']), "foo1bar12") /// assert_eq!("123foo1bar123".trim_left_chars(&|c: char| c.is_digit()), "foo1bar123") - /// ~~~ + /// ``` #[inline] fn trim_left_chars(&self, to_trim: &C) -> &'self str { match self.find(|c: char| !to_trim.matches(c)) { @@ -1892,11 +1892,11 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// assert_eq!("11foo1bar11".trim_right_chars(&'1'), "11foo1bar") /// assert_eq!("12foo1bar12".trim_right_chars(& &['1', '2']), "12foo1bar") /// assert_eq!("123foo1bar123".trim_right_chars(&|c: char| c.is_digit()), "123foo1bar") - /// ~~~ + /// ``` #[inline] fn trim_right_chars(&self, to_trim: &C) -> &'self str { match self.rfind(|c: char| !to_trim.matches(c)) { @@ -2000,7 +2000,7 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let s = "中华Việt Nam"; /// let i = 0u; /// while i < s.len() { @@ -2008,11 +2008,11 @@ impl<'self> StrSlice<'self> for &'self str { /// printfln!("%u: %c", i, ch); /// i = next; /// } - /// ~~~ + /// ``` /// /// # Example output /// - /// ~~~ + /// ``` /// 0: 中 /// 3: 华 /// 6: V @@ -2023,7 +2023,7 @@ impl<'self> StrSlice<'self> for &'self str { /// 13: N /// 14: a /// 15: m - /// ~~~ + /// ``` /// /// # Arguments /// @@ -2228,7 +2228,7 @@ impl<'self> StrSlice<'self> for &'self str { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let string = "a\nb\nc"; /// let mut lines = ~[]; /// for line in string.line_iter() { lines.push(line) } @@ -2236,7 +2236,7 @@ impl<'self> StrSlice<'self> for &'self str { /// assert!(string.subslice_offset(lines[0]) == 0); // &"a" /// assert!(string.subslice_offset(lines[1]) == 2); // &"b" /// assert!(string.subslice_offset(lines[2]) == 4); // &"c" - /// ~~~ + /// ``` #[inline] fn subslice_offset(&self, inner: &str) -> uint { do self.as_imm_buf |a, a_len| { diff --git a/src/libstd/task/mod.rs b/src/libstd/task/mod.rs index b52dd3a906b..1dbc644c8e5 100644 --- a/src/libstd/task/mod.rs +++ b/src/libstd/task/mod.rs @@ -26,11 +26,11 @@ * * # Example * - * ~~~ + * ``` * do spawn { * log(error, "Hello, World!"); * } - * ~~~ + * ``` */ #[allow(missing_doc)]; @@ -565,7 +565,7 @@ pub fn failing() -> bool { * * # Example * - * ~~~ + * ``` * do task::unkillable { * // detach / deschedule / destroy must all be called together * rustrt::rust_port_detach(po); @@ -573,7 +573,7 @@ pub fn failing() -> bool { * task::deschedule(); * rustrt::rust_port_destroy(po); * } - * ~~~ + * ``` */ pub fn unkillable(f: &fn() -> U) -> U { use rt::task::Task; @@ -602,7 +602,7 @@ pub fn unkillable(f: &fn() -> U) -> U { * * # Example * - * ~~~ + * ``` * do task::unkillable { * do task::rekillable { * // Task is killable diff --git a/src/libstd/unstable/finally.rs b/src/libstd/unstable/finally.rs index ba5986aa4ab..c1365a44bc9 100644 --- a/src/libstd/unstable/finally.rs +++ b/src/libstd/unstable/finally.rs @@ -14,13 +14,13 @@ stack closures that emulates Java-style try/finally blocks. # Example -~~~ + ``` do || { ... }.finally { always_run_this(); } -~~~ + ``` */ use ops::Drop; diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index ae217d6af31..e54717053e9 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -16,10 +16,10 @@ The `vec` module contains useful code to help work with vector values. Vectors are Rust's list type. Vectors contain zero or more values of homogeneous types: -~~~ {.rust} +```rust let int_vector = [1,2,3]; let str_vector = ["one", "two", "three"]; -~~~ + ``` This is a big module, but for a high-level overview: @@ -40,11 +40,11 @@ case. An example is the method `.slice(a, b)` that returns an immutable "view" into a vector or a vector slice from the index interval `[a, b)`: -~~~ {.rust} +```rust let numbers = [0, 1, 2]; let last_numbers = numbers.slice(1, 3); // last_numbers is now &[1, 2] -~~~ + ``` Traits defined for the `~[T]` type, like `OwnedVector`, can only be called on such vectors. These methods deal with adding elements or otherwise changing @@ -53,11 +53,11 @@ the allocation of the vector. An example is the method `.push(element)` that will add an element at the end of the vector: -~~~ {.rust} +```rust let mut numbers = ~[0, 1, 2]; numbers.push(7); // numbers is now ~[0, 1, 2, 7]; -~~~ + ``` ## Implementations of other traits @@ -74,12 +74,12 @@ The method `iter()` returns an iteration value for a vector or a vector slice. The iterator yields borrowed pointers to the vector's elements, so if the element type of the vector is `int`, the element type of the iterator is `&int`. -~~~ {.rust} +```rust let numbers = [0, 1, 2]; for &x in numbers.iter() { println!("{} is a number!", x); } -~~~ + ``` * `.rev_iter()` returns an iterator with the same values as `.iter()`, but going in the reverse order, starting with the back element. @@ -1000,12 +1000,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { * Print the adjacent pairs of a vector (i.e. `[1,2]`, `[2,3]`, * `[3,4]`): * - * ~~~ {.rust} + * ```rust * let v = &[1,2,3,4]; * for win in v.window_iter() { * printfln!(win); * } - * ~~~ + * ``` * */ fn window_iter(self, size: uint) -> WindowIter<'self, T> { @@ -1029,12 +1029,12 @@ impl<'self,T> ImmutableVector<'self, T> for &'self [T] { * Print the vector two elements at a time (i.e. `[1,2]`, * `[3,4]`, `[5]`): * - * ~~~ {.rust} + * ```rust * let v = &[1,2,3,4,5]; * for win in v.chunk_iter() { * printfln!(win); * } - * ~~~ + * ``` * */ fn chunk_iter(self, size: uint) -> ChunkIter<'self, T> { @@ -1279,13 +1279,13 @@ impl OwnedVector for ~[T] { /// /// # Examples /// - /// ~~~ {.rust} + /// ```rust /// let v = ~[~"a", ~"b"]; /// for s in v.move_iter() { /// // s has type ~str, not &~str /// println(s); /// } - /// ~~~ + /// ``` fn move_iter(self) -> MoveIterator { MoveIterator { v: self, idx: 0 } } @@ -1449,11 +1449,11 @@ impl OwnedVector for ~[T] { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let mut a = ~[~1]; /// a.push_all_move(~[~2, ~3, ~4]); /// assert!(a == ~[~1, ~2, ~3, ~4]); - /// ~~~ + /// ``` #[inline] fn push_all_move(&mut self, mut rhs: ~[T]) { let self_len = self.len(); @@ -1697,11 +1697,11 @@ impl OwnedCopyableVector for ~[T] { /// /// # Example /// - /// ~~~ {.rust} + /// ```rust /// let mut a = ~[1]; /// a.push_all([2, 3, 4]); /// assert!(a == ~[1, 2, 3, 4]); - /// ~~~ + /// ``` #[inline] fn push_all(&mut self, rhs: &[T]) { let new_len = self.len() + rhs.len(); diff --git a/src/libsyntax/ext/deriving/generic.rs b/src/libsyntax/ext/deriving/generic.rs index 9222d8160ee..646b65d080b 100644 --- a/src/libsyntax/ext/deriving/generic.rs +++ b/src/libsyntax/ext/deriving/generic.rs @@ -59,7 +59,7 @@ associated with. It is only not `None` when the associated field has an identifier in the source code. For example, the `x`s in the following snippet -~~~ + ``` struct A { x : int } struct B(int); @@ -82,7 +82,7 @@ represented as a count of 0. The following simplified `Eq` is used for in-code examples: -~~~ + ``` trait Eq { fn eq(&self, other: &Self); } @@ -91,7 +91,7 @@ impl Eq for int { *self == *other } } -~~~ + ``` Some examples of the values of `SubstructureFields` follow, using the above `Eq`, `A`, `B` and `C`. @@ -100,50 +100,50 @@ above `Eq`, `A`, `B` and `C`. When generating the `expr` for the `A` impl, the `SubstructureFields` is -~~~ + ``` Struct(~[(Some(), , ~[ ~[])]) -~~~ + ``` ## Enums When generating the `expr` for a call with `self == C0(a)` and `other == C0(b)`, the SubstructureFields is -~~~ + ``` EnumMatching(0, , ~[None, , ~[]]) -~~~ + ``` For `C1 {x}` and `C1 {x}`, -~~~ + ``` EnumMatching(1, , ~[Some(), , ~[]]) -~~~ + ``` For `C0(a)` and `C1 {x}` , -~~~ + ``` EnumNonMatching(~[(0, , ~[(None, )]), (1, , ~[(Some(), )])]) -~~~ + ``` (and vice versa, but with the order of the outermost list flipped.) @@ -158,7 +158,7 @@ StaticStruct(, Left(1)) StaticEnum(, ~[(, Left(1)), (, Right(~[]))]) -~~~ + ``` */ @@ -547,7 +547,7 @@ impl<'self> MethodDef<'self> { } /** - ~~~ + ``` #[deriving(Eq)] struct A { x: int, y: int } @@ -565,7 +565,7 @@ impl<'self> MethodDef<'self> { } } } - ~~~ + ``` */ fn expand_struct_method_body(&self, cx: @ExtCtxt, @@ -638,7 +638,7 @@ impl<'self> MethodDef<'self> { } /** - ~~~ + ``` #[deriving(Eq)] enum A { A1 @@ -661,7 +661,7 @@ impl<'self> MethodDef<'self> { } } } - ~~~ + ``` */ fn expand_enum_method_body(&self, cx: @ExtCtxt, @@ -681,13 +681,13 @@ impl<'self> MethodDef<'self> { /** Creates the nested matches for an enum definition recursively, i.e. - ~~~ + ``` match self { Variant1 => match other { Variant1 => matching, Variant2 => nonmatching, ... }, Variant2 => match other { Variant1 => nonmatching, Variant2 => matching, ... }, ... } - ~~~ + ``` It acts in the most naive way, so every branch (and subbranch, subsubbranch, etc) exists, not just the ones where all the variants in @@ -1058,10 +1058,10 @@ pub fn cs_fold(use_foldl: bool, Call the method that is being derived on all the fields, and then process the collected results. i.e. -~~~ + ``` f(cx, span, ~[self_1.method(__arg_1_1, __arg_2_1), self_2.method(__arg_1_2, __arg_2_2)]) -~~~ + ``` */ #[inline] pub fn cs_same_method(f: &fn(@ExtCtxt, Span, ~[@Expr]) -> @Expr, diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index 64f30803ca7..61c9ea7be14 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -944,7 +944,7 @@ pub fn std_macros() -> @str { # Example - ~~~ {.rust} + ```rust fn choose_weighted_item(v: &[Item]) -> Item { assert!(!v.is_empty()); let mut so_far = 0u; @@ -958,7 +958,7 @@ pub fn std_macros() -> @str { // type checker that it isn't possible to get down here unreachable!(); } - ~~~ + ``` */ macro_rules! unreachable (() => ( diff --git a/src/test/compile-fail/borrowck-anon-fields-struct.rs b/src/test/compile-fail/borrowck-anon-fields-struct.rs index 45a26068d82..bcaa3b9086c 100644 --- a/src/test/compile-fail/borrowck-anon-fields-struct.rs +++ b/src/test/compile-fail/borrowck-anon-fields-struct.rs @@ -34,4 +34,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-anon-fields-tuple.rs b/src/test/compile-fail/borrowck-anon-fields-tuple.rs index ae02245c97f..de2a8d83268 100644 --- a/src/test/compile-fail/borrowck-anon-fields-tuple.rs +++ b/src/test/compile-fail/borrowck-anon-fields-tuple.rs @@ -32,4 +32,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-anon-fields-variant.rs b/src/test/compile-fail/borrowck-anon-fields-variant.rs index 3d9738df059..da0a9323d2c 100644 --- a/src/test/compile-fail/borrowck-anon-fields-variant.rs +++ b/src/test/compile-fail/borrowck-anon-fields-variant.rs @@ -40,4 +40,4 @@ fn same_variant() { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs index ff1ec38ad64..c142876c5c2 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-free.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-free.rs @@ -40,4 +40,4 @@ fn explicit() { rewrite(&mut a)); //~ ERROR cannot borrow } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs index 0adf486b8b3..622d2e78ee7 100644 --- a/src/test/compile-fail/borrowck-bad-nested-calls-move.rs +++ b/src/test/compile-fail/borrowck-bad-nested-calls-move.rs @@ -40,4 +40,4 @@ fn explicit() { a); //~ ERROR cannot move } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs index c99a1ee60d7..628ccd1a5d7 100644 --- a/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs +++ b/src/test/compile-fail/borrowck-move-in-irrefut-pat.rs @@ -13,4 +13,4 @@ fn let_pat() { //~^ ERROR cannot move out of dereference of & pointer } -pub fn main() {} \ No newline at end of file +pub fn main() {} diff --git a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs index 6a3832d2304..565629b1c30 100644 --- a/src/test/compile-fail/borrowck-move-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-move-mut-base-ptr.rs @@ -12,4 +12,4 @@ fn foo(t0: &mut int) { } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs index bea5f1f6ea7..ab6f70945be 100644 --- a/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs +++ b/src/test/compile-fail/borrowck-swap-mut-base-ptr.rs @@ -13,4 +13,4 @@ fn foo<'a>(mut t0: &'a mut int, } fn main() { -} \ No newline at end of file +} diff --git a/src/test/compile-fail/cast-immutable-mutable-trait.rs b/src/test/compile-fail/cast-immutable-mutable-trait.rs index 1047a995771..0a94d6c4560 100644 --- a/src/test/compile-fail/cast-immutable-mutable-trait.rs +++ b/src/test/compile-fail/cast-immutable-mutable-trait.rs @@ -25,4 +25,4 @@ fn main() { let s = @S { unused: 0 }; let _s2 = s as @mut T; //~ error: types differ in mutability let _s3 = &s as &mut T; //~ error: types differ in mutability -} \ No newline at end of file +} diff --git a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs b/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs index a083757a0eb..ce58b260f61 100644 --- a/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs +++ b/src/test/compile-fail/cast-vector-to-unsafe-nonstatic.rs @@ -11,4 +11,4 @@ fn main() { let foo = ['h' as u8, 'i' as u8, 0 as u8]; let bar = &foo as *u8; //~ ERROR mismatched types -} \ No newline at end of file +} diff --git a/src/test/compile-fail/closure-bounds-not-builtin.rs b/src/test/compile-fail/closure-bounds-not-builtin.rs index a3484cb33dc..fbf1acb6066 100644 --- a/src/test/compile-fail/closure-bounds-not-builtin.rs +++ b/src/test/compile-fail/closure-bounds-not-builtin.rs @@ -5,4 +5,4 @@ fn take(f: &fn:Foo()) { //~^ ERROR only the builtin traits can be used as closure or object bounds } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/coherence_inherent.rs b/src/test/compile-fail/coherence_inherent.rs index 590c12826e4..2c3fbc827aa 100644 --- a/src/test/compile-fail/coherence_inherent.rs +++ b/src/test/compile-fail/coherence_inherent.rs @@ -42,4 +42,4 @@ mod NoImport { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/coherence_inherent_cc.rs b/src/test/compile-fail/coherence_inherent_cc.rs index 72c6df57c4f..40d733f8bab 100644 --- a/src/test/compile-fail/coherence_inherent_cc.rs +++ b/src/test/compile-fail/coherence_inherent_cc.rs @@ -35,4 +35,4 @@ mod NoImport { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/deprecated-auto-code.rs b/src/test/compile-fail/deprecated-auto-code.rs index 1f7cbfe9807..e4576e0f57c 100644 --- a/src/test/compile-fail/deprecated-auto-code.rs +++ b/src/test/compile-fail/deprecated-auto-code.rs @@ -12,4 +12,4 @@ #[auto_decode] //~ ERROR: `#[auto_decode]` is deprecated struct A; -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/issue-2995.rs b/src/test/compile-fail/issue-2995.rs index 3e771eef970..ea8ee8699e4 100644 --- a/src/test/compile-fail/issue-2995.rs +++ b/src/test/compile-fail/issue-2995.rs @@ -12,4 +12,4 @@ fn bad (p: *int) { let _q: &int = p as ∫ //~ ERROR non-scalar cast } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/compile-fail/issue-4736.rs b/src/test/compile-fail/issue-4736.rs index f7144b4c8fa..6f410ea3c37 100644 --- a/src/test/compile-fail/issue-4736.rs +++ b/src/test/compile-fail/issue-4736.rs @@ -12,4 +12,4 @@ struct NonCopyable(()); fn main() { let z = NonCopyable{ p: () }; //~ ERROR structure has no field named `p` -} \ No newline at end of file +} diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6762.rs index 391c1019a94..14dcc4ea8a3 100644 --- a/src/test/compile-fail/issue-6762.rs +++ b/src/test/compile-fail/issue-6762.rs @@ -21,4 +21,4 @@ fn main() twice(x); invoke(sq); -} \ No newline at end of file +} diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs index 358c6192147..6b5055cb1a2 100644 --- a/src/test/compile-fail/lub-if.rs +++ b/src/test/compile-fail/lub-if.rs @@ -49,4 +49,4 @@ pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/lub-match.rs b/src/test/compile-fail/lub-match.rs index 2a61b72997d..37b9cc55dc8 100644 --- a/src/test/compile-fail/lub-match.rs +++ b/src/test/compile-fail/lub-match.rs @@ -52,4 +52,4 @@ pub fn opt_str3<'a>(maybestr: &'a Option<~str>) -> &'static str { } } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/main-wrong-location.rs b/src/test/compile-fail/main-wrong-location.rs index 90ef7843d4b..ef3f8140c68 100644 --- a/src/test/compile-fail/main-wrong-location.rs +++ b/src/test/compile-fail/main-wrong-location.rs @@ -12,4 +12,4 @@ mod m { // An inferred main entry point (that doesn't use #[main]) // must appear at the top of the crate fn main() { } //~ NOTE here is a function named 'main' -} \ No newline at end of file +} diff --git a/src/test/compile-fail/regions-free-region-ordering-callee.rs b/src/test/compile-fail/regions-free-region-ordering-callee.rs index e5399fc7fa3..66ab4b77054 100644 --- a/src/test/compile-fail/regions-free-region-ordering-callee.rs +++ b/src/test/compile-fail/regions-free-region-ordering-callee.rs @@ -34,4 +34,4 @@ fn ordering4<'a, 'b>(a: &'a uint, b: &'b uint, x: &fn(&'a &'b uint)) { let z: Option<&'a &'b uint> = None; } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/regions-free-region-ordering-caller.rs b/src/test/compile-fail/regions-free-region-ordering-caller.rs index d06dcd8aa86..c9859899ea4 100644 --- a/src/test/compile-fail/regions-free-region-ordering-caller.rs +++ b/src/test/compile-fail/regions-free-region-ordering-caller.rs @@ -37,4 +37,4 @@ fn call4<'a, 'b>(a: &'a uint, b: &'b uint) { } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/regions-ref-in-fn-arg.rs b/src/test/compile-fail/regions-ref-in-fn-arg.rs index f90fe924587..48482627507 100644 --- a/src/test/compile-fail/regions-ref-in-fn-arg.rs +++ b/src/test/compile-fail/regions-ref-in-fn-arg.rs @@ -8,4 +8,4 @@ fn arg_closure() -> &'static int { with(|~ref x| x) //~ ERROR borrowed value does not live long enough } -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/compile-fail/suppressed-error.rs b/src/test/compile-fail/suppressed-error.rs index b4a72548cfc..e40bca58bad 100644 --- a/src/test/compile-fail/suppressed-error.rs +++ b/src/test/compile-fail/suppressed-error.rs @@ -11,4 +11,4 @@ fn main() { let (x, y) = (); //~ ERROR expected `()` but found tuple (types differ) return x; -} \ No newline at end of file +} diff --git a/src/test/compile-fail/tag-variant-disr-dup.rs b/src/test/compile-fail/tag-variant-disr-dup.rs index 216779fac7c..a5f85a685e6 100644 --- a/src/test/compile-fail/tag-variant-disr-dup.rs +++ b/src/test/compile-fail/tag-variant-disr-dup.rs @@ -20,4 +20,4 @@ enum color { white = 0x000000, } -fn main() { } \ No newline at end of file +fn main() { } diff --git a/src/test/compile-fail/type-parameter-names.rs b/src/test/compile-fail/type-parameter-names.rs index 6af3166a2ff..7c41c5d12e6 100644 --- a/src/test/compile-fail/type-parameter-names.rs +++ b/src/test/compile-fail/type-parameter-names.rs @@ -3,4 +3,4 @@ fn foo(x: Foo) -> Bar { x } //~ ERROR expected `Bar` but found `Foo` -fn main() {} \ No newline at end of file +fn main() {} diff --git a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs index 59e82a038bc..0e7572220a8 100644 --- a/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs +++ b/src/test/run-pass/borrowck-scope-of-deref-issue-4666.rs @@ -47,4 +47,4 @@ fn fun2() { pub fn main() { fun1(); fun2(); -} \ No newline at end of file +} diff --git a/src/test/run-pass/deriving-via-extension-struct-empty.rs b/src/test/run-pass/deriving-via-extension-struct-empty.rs index 8f6a3197986..74698b9db28 100644 --- a/src/test/run-pass/deriving-via-extension-struct-empty.rs +++ b/src/test/run-pass/deriving-via-extension-struct-empty.rs @@ -14,4 +14,4 @@ struct Foo; pub fn main() { assert_eq!(Foo, Foo); assert!(!(Foo != Foo)); -} \ No newline at end of file +} diff --git a/src/test/run-pass/issue-4252.rs b/src/test/run-pass/issue-4252.rs index 121757fb590..c7ba345517c 100644 --- a/src/test/run-pass/issue-4252.rs +++ b/src/test/run-pass/issue-4252.rs @@ -34,4 +34,4 @@ impl Drop for Z { fn main() { let y = Y; let _z = Z{x: y}; -} \ No newline at end of file +} diff --git a/src/test/run-pass/xc_conditions_client.rs b/src/test/run-pass/xc_conditions_client.rs index ffef5369f23..730ed18fbbd 100644 --- a/src/test/run-pass/xc_conditions_client.rs +++ b/src/test/run-pass/xc_conditions_client.rs @@ -37,4 +37,4 @@ pub fn main() { let x = trouble(); assert_eq!(x,12345); } -} \ No newline at end of file +} diff --git a/src/test/run-pass/xc_conditions_client_4.rs b/src/test/run-pass/xc_conditions_client_4.rs index 9a4a8683742..69ddb3701b0 100644 --- a/src/test/run-pass/xc_conditions_client_4.rs +++ b/src/test/run-pass/xc_conditions_client_4.rs @@ -29,4 +29,4 @@ pub fn main() { let t = SThunk { x : 10 }; assert_eq!(xcc::callback(t), xcc::Red) } -} \ No newline at end of file +}