syntax highlight code examples in docstrings
This commit is contained in:
parent
3941f78a1b
commit
0d5fdce82e
17 changed files with 165 additions and 117 deletions
|
|
@ -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}
|
||||
* extern mod std;
|
||||
* use std::arc;
|
||||
* let numbers=vec::from_fn(100, |ind| (ind as float)*rand::random());
|
||||
|
|
@ -370,7 +370,10 @@ pub impl<T:Const + Owned> RWARC<T> {
|
|||
* See sync::rwlock.write_downgrade(). The RWWriteMode token must be used
|
||||
* to obtain the &mut T, and can be transformed into a RWReadMode token by
|
||||
* calling downgrade(), after which a &T can be obtained instead.
|
||||
* ~~~
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ~~~ {.rust}
|
||||
* do arc.write_downgrade |write_mode| {
|
||||
* do (&write_mode).write_cond |state, condvar| {
|
||||
* ... exclusive access with mutable state ...
|
||||
|
|
|
|||
|
|
@ -28,9 +28,9 @@ impl<'self> ToBase64 for &'self [u8] {
|
|||
/**
|
||||
* Turn a vector of `u8` bytes into a base64 string.
|
||||
*
|
||||
* *Example*:
|
||||
* # Example
|
||||
*
|
||||
* ~~~~
|
||||
* ~~~ {.rust}
|
||||
* extern mod std;
|
||||
* use std::base64::ToBase64;
|
||||
*
|
||||
|
|
@ -38,7 +38,7 @@ impl<'self> ToBase64 for &'self [u8] {
|
|||
* let str = [52,32].to_base64();
|
||||
* println(fmt!("%s", str));
|
||||
* }
|
||||
* ~~~~
|
||||
* ~~~
|
||||
*/
|
||||
fn to_base64(&self) -> ~str {
|
||||
let mut s = ~"";
|
||||
|
|
@ -91,9 +91,9 @@ impl<'self> ToBase64 for &'self str {
|
|||
* Convert any string (literal, `@`, `&`, or `~`) to base64 encoding.
|
||||
*
|
||||
*
|
||||
* *Example*:
|
||||
* # Example
|
||||
*
|
||||
* ~~~~
|
||||
* ~~~ {.rust}
|
||||
* extern mod std;
|
||||
* use std::base64::ToBase64;
|
||||
*
|
||||
|
|
@ -101,7 +101,7 @@ impl<'self> ToBase64 for &'self str {
|
|||
* let str = "Hello, World".to_base64();
|
||||
* println(fmt!("%s",str));
|
||||
* }
|
||||
* ~~~~
|
||||
* ~~~
|
||||
*
|
||||
*/
|
||||
fn to_base64(&self) -> ~str {
|
||||
|
|
@ -118,9 +118,9 @@ impl FromBase64 for ~[u8] {
|
|||
* Convert base64 `u8` vector into u8 byte values.
|
||||
* Every 4 encoded characters is converted into 3 octets, modulo padding.
|
||||
*
|
||||
* *Example*:
|
||||
* # Example
|
||||
*
|
||||
* ~~~~
|
||||
* ~~~ {.rust}
|
||||
* extern mod std;
|
||||
* use std::base64::ToBase64;
|
||||
* use std::base64::FromBase64;
|
||||
|
|
@ -131,7 +131,7 @@ impl FromBase64 for ~[u8] {
|
|||
* let bytes = str.from_base64();
|
||||
* println(fmt!("%?",bytes));
|
||||
* }
|
||||
* ~~~~
|
||||
* ~~~
|
||||
*/
|
||||
fn from_base64(&self) -> ~[u8] {
|
||||
if self.len() % 4u != 0u { fail!("invalid base64 length"); }
|
||||
|
|
@ -196,11 +196,11 @@ impl FromBase64 for ~str {
|
|||
* You can use the `from_bytes` function in `core::str`
|
||||
* to turn a `[u8]` into a string with characters corresponding to those values.
|
||||
*
|
||||
* *Example*:
|
||||
* # Example
|
||||
*
|
||||
* This converts a string literal to base64 and back.
|
||||
*
|
||||
* ~~~~
|
||||
* ~~~ {.rust}
|
||||
* extern mod std;
|
||||
* use std::base64::ToBase64;
|
||||
* use std::base64::FromBase64;
|
||||
|
|
@ -214,7 +214,7 @@ impl FromBase64 for ~str {
|
|||
* let result_str = str::from_bytes(bytes);
|
||||
* println(fmt!("%s",result_str));
|
||||
* }
|
||||
* ~~~~
|
||||
* ~~~
|
||||
*/
|
||||
fn from_base64(&self) -> ~[u8] {
|
||||
str::to_bytes(*self).from_base64()
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ ports and channels.
|
|||
|
||||
This example sends boxed integers across tasks using serialization.
|
||||
|
||||
~~~
|
||||
~~~ {.rust}
|
||||
let (port, chan) = serial::pipe_stream();
|
||||
|
||||
do task::spawn || {
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
*
|
||||
* # Example
|
||||
*
|
||||
* ~~~
|
||||
* ~~~ {.rust}
|
||||
* # fn fib(n: uint) -> uint {42};
|
||||
* # fn make_a_sandwich() {};
|
||||
* let mut delayed_fib = std::future::spawn (|| fib(5000) );
|
||||
|
|
|
|||
|
|
@ -466,7 +466,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
|
|||
* Here, the `new_conn` is used in conjunction with `accept` from within
|
||||
* a task spawned by the `new_connect_cb` passed into `listen`
|
||||
*
|
||||
* ~~~~~~~~~~~
|
||||
* ~~~ {.rust}
|
||||
* do net::tcp::listen(remote_ip, remote_port, backlog, iotask,
|
||||
* // this callback is ran once after the connection is successfully
|
||||
* // set up
|
||||
|
|
@ -497,7 +497,7 @@ fn read_future(sock: &TcpSocket, timeout_msecs: uint)
|
|||
* None => ()
|
||||
* }
|
||||
* };
|
||||
* ~~~~~~~~~~~
|
||||
* ~~~
|
||||
*
|
||||
* # Arguments
|
||||
*
|
||||
|
|
|
|||
|
|
@ -545,7 +545,10 @@ pub impl RWlock {
|
|||
* the meantime (such as unlocking and then re-locking as a reader would
|
||||
* do). The block takes a "write mode token" argument, which can be
|
||||
* transformed into a "read mode token" by calling downgrade(). Example:
|
||||
* ~~~
|
||||
*
|
||||
* # Example
|
||||
*
|
||||
* ~~~ {.rust}
|
||||
* do lock.write_downgrade |write_mode| {
|
||||
* do (&write_mode).write_cond |condvar| {
|
||||
* ... exclusive access ...
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue