diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2013-09-23 17:20:36 -0700 | 
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2013-09-25 14:27:42 -0700 | 
| commit | 3585c64d092082ab2aa16a6d674d063c5d68e1a8 (patch) | |
| tree | 0474a6b6ae66322964afdef0ddff18c5af3ef73f /src/libstd/condition.rs | |
| parent | db28c2998015446dd4f3c9615484f0666225aa60 (diff) | |
| download | rust-3585c64d092082ab2aa16a6d674d063c5d68e1a8.tar.gz rust-3585c64d092082ab2aa16a6d674d063c5d68e1a8.zip  | |
rustdoc: Change all code-blocks with a script
    find src -name '*.rs' | xargs sed -i '' 's/~~~.*{\.rust}/```rust/g'
    find src -name '*.rs' | xargs sed -i '' 's/ ~~~$/ ```/g'
    find src -name '*.rs' | xargs sed -i '' 's/^~~~$/ ```/g'
Diffstat (limited to 'src/libstd/condition.rs')
| -rw-r--r-- | src/libstd/condition.rs | 16 | 
1 files changed, 8 insertions, 8 deletions
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<T, U> Condition<T, U> { /// /// # 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<V>(&self, inner: &'self fn() -> V) -> V { let _g = Guard { cond: self.cond }; debug!("Trap: pushing handler to TLS");  | 
