auto merge of #10974 : huonw/rust/spellck, r=alexcrichton
This commit is contained in:
commit
ef7969e86f
@ -276,7 +276,7 @@ impl<T:Freeze + Send> MutexArc<T> {
|
|||||||
* might contain nested MutexArcs inside.
|
* might contain nested MutexArcs inside.
|
||||||
*
|
*
|
||||||
* The purpose of this is to offer a safe implementation of MutexArc to be
|
* The purpose of this is to offer a safe implementation of MutexArc to be
|
||||||
* used instead of RWArc in cases where no readers are needed and sightly
|
* used instead of RWArc in cases where no readers are needed and slightly
|
||||||
* better performance is required.
|
* better performance is required.
|
||||||
*
|
*
|
||||||
* Both methods have the same failure behaviour as unsafe_access and
|
* Both methods have the same failure behaviour as unsafe_access and
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
//! file name following `-o`, and accepts both `-h` and `--help` as optional flags.
|
//! file name following `-o`, and accepts both `-h` and `--help` as optional flags.
|
||||||
//!
|
//!
|
||||||
//! ~~~{.rust}
|
//! ~~~{.rust}
|
||||||
//! exter mod extra;
|
//! extern mod extra;
|
||||||
//! use extra::getopts::*;
|
//! use extra::getopts::*;
|
||||||
//! use std::os;
|
//! use std::os;
|
||||||
//!
|
//!
|
||||||
@ -114,7 +114,7 @@ pub enum Occur {
|
|||||||
pub struct Opt {
|
pub struct Opt {
|
||||||
/// Name of the option
|
/// Name of the option
|
||||||
name: Name,
|
name: Name,
|
||||||
/// Wheter it has an argument
|
/// Whether it has an argument
|
||||||
hasarg: HasArg,
|
hasarg: HasArg,
|
||||||
/// How often it can occur
|
/// How often it can occur
|
||||||
occur: Occur,
|
occur: Occur,
|
||||||
@ -154,7 +154,7 @@ pub enum Fail_ {
|
|||||||
UnexpectedArgument(~str),
|
UnexpectedArgument(~str),
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The type of failure that occured.
|
/// The type of failure that occurred.
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq)]
|
||||||
#[allow(missing_doc)]
|
#[allow(missing_doc)]
|
||||||
pub enum FailType {
|
pub enum FailType {
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
use std::io::fs;
|
use std::io::fs;
|
||||||
|
|
||||||
/// A wrapper for a path to temporary directory implementing automatic
|
/// A wrapper for a path to temporary directory implementing automatic
|
||||||
/// scope-pased deletion.
|
/// scope-based deletion.
|
||||||
pub struct TempDir {
|
pub struct TempDir {
|
||||||
priv path: Option<Path>
|
priv path: Option<Path>
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
They are particularly useful in distributed systems, though can be used in
|
They are particularly useful in distributed systems, though can be used in
|
||||||
disparate areas, such as databases and network protocols. Typically a UUID is
|
disparate areas, such as databases and network protocols. Typically a UUID is
|
||||||
displayed in a readable string form as a sequence of hexadecimals digits,
|
displayed in a readable string form as a sequence of hexadecimal digits,
|
||||||
separated into groups by hyphens.
|
separated into groups by hyphens.
|
||||||
|
|
||||||
The uniqueness property is not strictly guaranteed, however for all practical
|
The uniqueness property is not strictly guaranteed, however for all practical
|
||||||
@ -89,11 +89,11 @@ pub enum UuidVersion {
|
|||||||
/// The reserved variants of UUIDs
|
/// The reserved variants of UUIDs
|
||||||
#[deriving(Eq)]
|
#[deriving(Eq)]
|
||||||
pub enum UuidVariant {
|
pub enum UuidVariant {
|
||||||
/// Reserved by the NCS for backward compatability
|
/// Reserved by the NCS for backward compatibility
|
||||||
VariantNCS,
|
VariantNCS,
|
||||||
/// As described in the RFC4122 Specification (default)
|
/// As described in the RFC4122 Specification (default)
|
||||||
VariantRFC4122,
|
VariantRFC4122,
|
||||||
/// Resreved by Microsoft for backward compatability
|
/// Reserved by Microsoft for backward compatibility
|
||||||
VariantMicrosoft,
|
VariantMicrosoft,
|
||||||
/// Reserved for future expansion
|
/// Reserved for future expansion
|
||||||
VariantFuture,
|
VariantFuture,
|
||||||
@ -313,7 +313,7 @@ pub fn to_simple_str(&self) -> ~str {
|
|||||||
str::from_utf8_owned(s)
|
str::from_utf8_owned(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a string of hexadecimal digits, separated into groups with a hypen
|
/// Returns a string of hexadecimal digits, separated into groups with a hyphen.
|
||||||
///
|
///
|
||||||
/// Example: `550e8400-e29b-41d4-a716-446655440000`
|
/// Example: `550e8400-e29b-41d4-a716-446655440000`
|
||||||
pub fn to_hyphenated_str(&self) -> ~str {
|
pub fn to_hyphenated_str(&self) -> ~str {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
use uvll;
|
use uvll;
|
||||||
use super::{Loop, UvHandle};
|
use super::{Loop, UvHandle};
|
||||||
use std::rt::rtio::{Callback, PausibleIdleCallback};
|
use std::rt::rtio::{Callback, PausableIdleCallback};
|
||||||
|
|
||||||
pub struct IdleWatcher {
|
pub struct IdleWatcher {
|
||||||
handle: *uvll::uv_idle_t,
|
handle: *uvll::uv_idle_t,
|
||||||
@ -63,7 +63,7 @@ pub fn onetime(loop_: &mut Loop, f: proc()) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PausibleIdleCallback for IdleWatcher {
|
impl PausableIdleCallback for IdleWatcher {
|
||||||
fn pause(&mut self) {
|
fn pause(&mut self) {
|
||||||
if self.idle_flag == true {
|
if self.idle_flag == true {
|
||||||
assert_eq!(unsafe {uvll::uv_idle_stop(self.handle) }, 0);
|
assert_eq!(unsafe {uvll::uv_idle_stop(self.handle) }, 0);
|
||||||
@ -99,7 +99,7 @@ fn drop(&mut self) {
|
|||||||
mod test {
|
mod test {
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::rt::tube::Tube;
|
use std::rt::tube::Tube;
|
||||||
use std::rt::rtio::{Callback, PausibleIdleCallback};
|
use std::rt::rtio::{Callback, PausableIdleCallback};
|
||||||
use super::super::local_loop;
|
use super::super::local_loop;
|
||||||
|
|
||||||
struct MyCallback(Tube<int>, int);
|
struct MyCallback(Tube<int>, int);
|
||||||
|
@ -153,8 +153,8 @@ fn callback(&mut self, f: proc()) {
|
|||||||
IdleWatcher::onetime(self.uvio.uv_loop(), f);
|
IdleWatcher::onetime(self.uvio.uv_loop(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pausible_idle_callback(&mut self, cb: ~Callback) -> ~PausibleIdleCallback {
|
fn pausable_idle_callback(&mut self, cb: ~Callback) -> ~PausableIdleCallback {
|
||||||
IdleWatcher::new(self.uvio.uv_loop(), cb) as ~PausibleIdleCallback
|
IdleWatcher::new(self.uvio.uv_loop(), cb) as ~PausableIdleCallback
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
|
fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
|
||||||
|
@ -81,7 +81,7 @@ pub fn borrow<'a>(&'a self) -> Ref<'a, T> {
|
|||||||
|
|
||||||
/// Mutably borrows the wrapped value.
|
/// Mutably borrows the wrapped value.
|
||||||
///
|
///
|
||||||
/// The borrow lasts untile the returned `RefMut` exits scope. The value
|
/// The borrow lasts until the returned `RefMut` exits scope. The value
|
||||||
/// cannot be borrowed while this borrow is active.
|
/// cannot be borrowed while this borrow is active.
|
||||||
///
|
///
|
||||||
/// Returns `None` if the value is currently borrowed.
|
/// Returns `None` if the value is currently borrowed.
|
||||||
@ -98,7 +98,7 @@ pub fn try_borrow_mut<'a>(&'a self) -> Option<RefMut<'a, T>> {
|
|||||||
|
|
||||||
/// Mutably borrows the wrapped value.
|
/// Mutably borrows the wrapped value.
|
||||||
///
|
///
|
||||||
/// The borrow lasts untile the returned `RefMut` exits scope. The value
|
/// The borrow lasts until the returned `RefMut` exits scope. The value
|
||||||
/// cannot be borrowed while this borrow is active.
|
/// cannot be borrowed while this borrow is active.
|
||||||
///
|
///
|
||||||
/// # Failure
|
/// # Failure
|
||||||
|
@ -256,7 +256,7 @@ fn decompose_hangul(s: char, f: |char|) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the canonical decompostion of a character
|
/// Returns the canonical decomposition of a character.
|
||||||
pub fn decompose_canonical(c: char, f: |char|) {
|
pub fn decompose_canonical(c: char, f: |char|) {
|
||||||
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
|
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
|
||||||
decompose::canonical(c, f);
|
decompose::canonical(c, f);
|
||||||
@ -265,7 +265,7 @@ pub fn decompose_canonical(c: char, f: |char|) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the compatibility decompostion of a character
|
/// Returns the compatibility decomposition of a character.
|
||||||
pub fn decompose_compatible(c: char, f: |char|) {
|
pub fn decompose_compatible(c: char, f: |char|) {
|
||||||
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
|
if (c as uint) < S_BASE || (c as uint) >= (S_BASE + S_COUNT) {
|
||||||
decompose::compatibility(c, f);
|
decompose::compatibility(c, f);
|
||||||
|
@ -33,7 +33,7 @@ pub trait Clone {
|
|||||||
/// Perform copy-assignment from `source`.
|
/// Perform copy-assignment from `source`.
|
||||||
///
|
///
|
||||||
/// `a.clone_from(&b)` is equivalent to `a = b.clone()` in functionality,
|
/// `a.clone_from(&b)` is equivalent to `a = b.clone()` in functionality,
|
||||||
/// but can be overriden to reuse the resources of `a` to avoid unnecessary
|
/// but can be overridden to reuse the resources of `a` to avoid unnecessary
|
||||||
/// allocations.
|
/// allocations.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn clone_from(&mut self, source: &Self) {
|
fn clone_from(&mut self, source: &Self) {
|
||||||
@ -141,7 +141,7 @@ pub trait DeepClone: Clone {
|
|||||||
/// Perform deep copy-assignment from `source`.
|
/// Perform deep copy-assignment from `source`.
|
||||||
///
|
///
|
||||||
/// `a.deep_clone_from(&b)` is equivalent to `a = b.deep_clone()` in
|
/// `a.deep_clone_from(&b)` is equivalent to `a = b.deep_clone()` in
|
||||||
/// functionality, but can be overriden to reuse the resources of `a` to
|
/// functionality, but can be overridden to reuse the resources of `a` to
|
||||||
/// avoid unnecessary allocations.
|
/// avoid unnecessary allocations.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn deep_clone_from(&mut self, source: &Self) {
|
fn deep_clone_from(&mut self, source: &Self) {
|
||||||
|
@ -81,7 +81,7 @@ pub struct Handler<T, U> {
|
|||||||
/// the condition (useful for debugging).
|
/// the condition (useful for debugging).
|
||||||
///
|
///
|
||||||
/// This struct should never be created directly, but rather only through the
|
/// This struct should never be created directly, but rather only through the
|
||||||
/// `condition!` macro provided to all libraries using libstd.
|
/// `condition!` macro provided to all libraries using `std`.
|
||||||
pub struct Condition<T, U> {
|
pub struct Condition<T, U> {
|
||||||
/// Name of the condition handler
|
/// Name of the condition handler
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
|
@ -606,9 +606,9 @@ pub fn writeln(output: &mut io::Writer, args: &Arguments) {
|
|||||||
/// See the documentation for `format` for why this function is unsafe and care
|
/// See the documentation for `format` for why this function is unsafe and care
|
||||||
/// should be taken if calling it manually.
|
/// should be taken if calling it manually.
|
||||||
///
|
///
|
||||||
/// Thankfully the rust compiler provides the macro `fmtf!` which will perform
|
/// Thankfully the rust compiler provides macros like `write!` and
|
||||||
/// all of this validation at compile-time and provides a safe interface for
|
/// `format_args!` which perform all of this validation at compile-time
|
||||||
/// invoking this function.
|
/// and provide a safe interface for invoking this function.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
///
|
///
|
||||||
|
@ -202,8 +202,8 @@ fn inner_ref<'a>(&'a self) -> &'a W { &self.inner }
|
|||||||
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut W { &mut self.inner }
|
fn inner_mut_ref<'a>(&'a mut self) -> &'a mut W { &mut self.inner }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wraps a Writer and buffers output to it, flushing whenever a newline (0xa,
|
/// Wraps a Writer and buffers output to it, flushing whenever a newline (`0x0a`,
|
||||||
/// '\n') is detected.
|
/// `'\n'`) is detected.
|
||||||
///
|
///
|
||||||
/// Note that this structure does NOT flush the output when dropped.
|
/// Note that this structure does NOT flush the output when dropped.
|
||||||
pub struct LineBufferedWriter<W> {
|
pub struct LineBufferedWriter<W> {
|
||||||
|
@ -249,7 +249,7 @@ pub fn unlink(path: &Path) {
|
|||||||
/// directory, etc. This function will traverse symlinks to query
|
/// directory, etc. This function will traverse symlinks to query
|
||||||
/// information about the destination file.
|
/// information about the destination file.
|
||||||
///
|
///
|
||||||
/// Returns a fully-filled out stat structure on succes, and on failure it
|
/// Returns a fully-filled out stat structure on success, and on failure it
|
||||||
/// will return a dummy stat structure (it is expected that the condition
|
/// will return a dummy stat structure (it is expected that the condition
|
||||||
/// raised is handled as well).
|
/// raised is handled as well).
|
||||||
///
|
///
|
||||||
@ -342,7 +342,7 @@ pub fn rename(from: &Path, to: &Path) {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Will raise an `io_error` condition is the following situtations, but is
|
/// Will raise an `io_error` condition is the following situations, but is
|
||||||
/// not limited to just these cases:
|
/// not limited to just these cases:
|
||||||
///
|
///
|
||||||
/// * The `from` path is not a file
|
/// * The `from` path is not a file
|
||||||
@ -391,7 +391,7 @@ pub fn copy(from: &Path, to: &Path) {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// If this funciton encounters an I/O error, it will raise on the `io_error`
|
/// If this function encounters an I/O error, it will raise on the `io_error`
|
||||||
/// condition. Some possible error situations are not having the permission to
|
/// condition. Some possible error situations are not having the permission to
|
||||||
/// change the attributes of a file or the file not existing.
|
/// change the attributes of a file or the file not existing.
|
||||||
pub fn chmod(path: &Path, mode: io::FilePermission) {
|
pub fn chmod(path: &Path, mode: io::FilePermission) {
|
||||||
@ -402,7 +402,7 @@ pub fn chmod(path: &Path, mode: io::FilePermission) {
|
|||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// This funtion will raise on the `io_error` condition on failure.
|
/// This function will raise on the `io_error` condition on failure.
|
||||||
pub fn chown(path: &Path, uid: int, gid: int) {
|
pub fn chown(path: &Path, uid: int, gid: int) {
|
||||||
io_raise(|io| io.fs_chown(&path.to_c_str(), uid, gid));
|
io_raise(|io| io.fs_chown(&path.to_c_str(), uid, gid));
|
||||||
}
|
}
|
||||||
@ -448,7 +448,7 @@ pub fn readlink(path: &Path) -> Option<Path> {
|
|||||||
///
|
///
|
||||||
/// let p = Path::new("/some/dir");
|
/// let p = Path::new("/some/dir");
|
||||||
/// fs::mkdir(&p, S_IRWXU as int);
|
/// fs::mkdir(&p, S_IRWXU as int);
|
||||||
/// // If we got here, our directory exists! Horray!
|
/// // If we got here, our directory exists! Hooray!
|
||||||
///
|
///
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
@ -665,7 +665,7 @@ pub fn exists(&self) -> bool {
|
|||||||
io::result(|| self.stat()).is_ok()
|
io::result(|| self.stat()).is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the underlying implemention (be it a file path, or something
|
/// Whether the underlying implementation (be it a file path, or something
|
||||||
/// else) points at a "regular file" on the FS. Will return false for paths
|
/// else) points at a "regular file" on the FS. Will return false for paths
|
||||||
/// to non-existent locations or directories or other non-regular files
|
/// to non-existent locations or directories or other non-regular files
|
||||||
/// (named pipes, etc).
|
/// (named pipes, etc).
|
||||||
@ -680,7 +680,7 @@ pub fn is_file(&self) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Whether the underlying implemention (be it a file path,
|
/// Whether the underlying implementation (be it a file path,
|
||||||
/// or something else) is pointing at a directory in the underlying FS.
|
/// or something else) is pointing at a directory in the underlying FS.
|
||||||
/// Will return false for paths to non-existent locations or if the item is
|
/// Will return false for paths to non-existent locations or if the item is
|
||||||
/// not a directory (eg files, named pipes, links, etc)
|
/// not a directory (eg files, named pipes, links, etc)
|
||||||
|
@ -835,7 +835,7 @@ pub trait Writer {
|
|||||||
/// Flush this output stream, ensuring that all intermediately buffered
|
/// Flush this output stream, ensuring that all intermediately buffered
|
||||||
/// contents reach their destination.
|
/// contents reach their destination.
|
||||||
///
|
///
|
||||||
/// This is by default a no-op and implementors of the `Writer` trait should
|
/// This is by default a no-op and implementers of the `Writer` trait should
|
||||||
/// decide whether their stream needs to be buffered or not.
|
/// decide whether their stream needs to be buffered or not.
|
||||||
fn flush(&mut self) {}
|
fn flush(&mut self) {}
|
||||||
|
|
||||||
@ -1057,7 +1057,7 @@ fn lines<'r>(&'r mut self) -> LineIterator<'r, Self> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a sequence of bytes leading up to a specified delimeter. Once the
|
/// Reads a sequence of bytes leading up to a specified delimiter. Once the
|
||||||
/// specified byte is encountered, reading ceases and the bytes up to and
|
/// specified byte is encountered, reading ceases and the bytes up to and
|
||||||
/// including the delimiter are returned.
|
/// including the delimiter are returned.
|
||||||
///
|
///
|
||||||
@ -1156,7 +1156,7 @@ pub trait Seek {
|
|||||||
/// A listener is a value that can consume itself to start listening for connections.
|
/// A listener is a value that can consume itself to start listening for connections.
|
||||||
/// Doing so produces some sort of Acceptor.
|
/// Doing so produces some sort of Acceptor.
|
||||||
pub trait Listener<T, A: Acceptor<T>> {
|
pub trait Listener<T, A: Acceptor<T>> {
|
||||||
/// Spin up the listener and start queueing incoming connections
|
/// Spin up the listener and start queuing incoming connections
|
||||||
///
|
///
|
||||||
/// # Failure
|
/// # Failure
|
||||||
///
|
///
|
||||||
|
@ -50,7 +50,7 @@ impl Process {
|
|||||||
/// * prog - the program to run
|
/// * prog - the program to run
|
||||||
/// * args - the arguments to pass to the program, not including the program
|
/// * args - the arguments to pass to the program, not including the program
|
||||||
/// itself
|
/// itself
|
||||||
/// * env - an optional envrionment to specify for the child process. If
|
/// * env - an optional environment to specify for the child process. If
|
||||||
/// this value is `None`, then the child will inherit the parent's
|
/// this value is `None`, then the child will inherit the parent's
|
||||||
/// environment
|
/// environment
|
||||||
/// * cwd - an optionally specified current working directory of the child,
|
/// * cwd - an optionally specified current working directory of the child,
|
||||||
|
@ -34,7 +34,7 @@ pub enum Signum {
|
|||||||
Break = 21i,
|
Break = 21i,
|
||||||
/// Equivalent to SIGHUP, delivered when the user closes the terminal
|
/// Equivalent to SIGHUP, delivered when the user closes the terminal
|
||||||
/// window. On delivery of HangUp, the program is given approximately
|
/// window. On delivery of HangUp, the program is given approximately
|
||||||
/// 10 seconds to perfom any cleanup. After that, Windows will
|
/// 10 seconds to perform any cleanup. After that, Windows will
|
||||||
/// unconditionally terminate it.
|
/// unconditionally terminate it.
|
||||||
HangUp = 1i,
|
HangUp = 1i,
|
||||||
/// Equivalent to SIGINT, delivered when the user presses Ctrl-c.
|
/// Equivalent to SIGINT, delivered when the user presses Ctrl-c.
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
# The `Iterator` trait
|
# The `Iterator` trait
|
||||||
|
|
||||||
This module defines Rust's core iteration trait. The `Iterator` trait has one
|
This module defines Rust's core iteration trait. The `Iterator` trait has one
|
||||||
un-implemented method, `next`. All other methods are derived through default
|
unimplemented method, `next`. All other methods are derived through default
|
||||||
methods to perform operations such as `zip`, `chain`, `enumerate`, and `fold`.
|
methods to perform operations such as `zip`, `chain`, `enumerate`, and `fold`.
|
||||||
|
|
||||||
The goal of this module is to unify iteration across all containers in Rust.
|
The goal of this module is to unify iteration across all containers in Rust.
|
||||||
@ -1688,7 +1688,7 @@ fn idx(&self, index: uint) -> Option<A> {
|
|||||||
|
|
||||||
impl<T> Fuse<T> {
|
impl<T> Fuse<T> {
|
||||||
/// Resets the fuse such that the next call to .next() or .next_back() will
|
/// Resets the fuse such that the next call to .next() or .next_back() will
|
||||||
/// call the underlying iterator again even if it prevously returned None.
|
/// call the underlying iterator again even if it previously returned None.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn reset_fuse(&mut self) {
|
pub fn reset_fuse(&mut self) {
|
||||||
self.done = false
|
self.done = false
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
foreign code with bad callback interfaces.
|
foreign code with bad callback interfaces.
|
||||||
|
|
||||||
To declare a new key for storing local data of a particular type, use the
|
To declare a new key for storing local data of a particular type, use the
|
||||||
`local_data_key!` macro. This macro will expand to a `static` item apppriately
|
`local_data_key!` macro. This macro will expand to a `static` item appropriately
|
||||||
named and annotated. This name is then passed to the functions in this module to
|
named and annotated. This name is then passed to the functions in this module to
|
||||||
modify/read the slot specified by the key.
|
modify/read the slot specified by the key.
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ pub trait Fractional: Num
|
|||||||
pub trait Algebraic {
|
pub trait Algebraic {
|
||||||
/// Raise a number to a power.
|
/// Raise a number to a power.
|
||||||
fn pow(&self, n: &Self) -> Self;
|
fn pow(&self, n: &Self) -> Self;
|
||||||
/// Take the squre root of a number.
|
/// Take the square root of a number.
|
||||||
fn sqrt(&self) -> Self;
|
fn sqrt(&self) -> Self;
|
||||||
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
||||||
fn rsqrt(&self) -> Self;
|
fn rsqrt(&self) -> Self;
|
||||||
@ -229,7 +229,7 @@ pub trait Algebraic {
|
|||||||
/// assert_eq!(sixteen, 16.0);
|
/// assert_eq!(sixteen, 16.0);
|
||||||
/// ```
|
/// ```
|
||||||
#[inline(always)] pub fn pow<T: Algebraic>(value: T, n: T) -> T { value.pow(&n) }
|
#[inline(always)] pub fn pow<T: Algebraic>(value: T, n: T) -> T { value.pow(&n) }
|
||||||
/// Take the squre root of a number.
|
/// Take the square root of a number.
|
||||||
#[inline(always)] pub fn sqrt<T: Algebraic>(value: T) -> T { value.sqrt() }
|
#[inline(always)] pub fn sqrt<T: Algebraic>(value: T) -> T { value.sqrt() }
|
||||||
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
/// Take the reciprocal (inverse) square root of a number, `1/sqrt(x)`.
|
||||||
#[inline(always)] pub fn rsqrt<T: Algebraic>(value: T) -> T { value.rsqrt() }
|
#[inline(always)] pub fn rsqrt<T: Algebraic>(value: T) -> T { value.rsqrt() }
|
||||||
|
@ -352,7 +352,7 @@ pub trait BitOr<RHS,Result> {
|
|||||||
* # Example
|
* # Example
|
||||||
*
|
*
|
||||||
* A trivial implementation of `BitXor`. When `Foo ^ Foo` happens, it ends up
|
* A trivial implementation of `BitXor`. When `Foo ^ Foo` happens, it ends up
|
||||||
* calling `bixtor`, and therefore, `main` prints `Bitwise Xor-ing!`.
|
* calling `bitxor`, and therefore, `main` prints `Bitwise Xor-ing!`.
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* struct Foo;
|
* struct Foo;
|
||||||
|
@ -45,7 +45,7 @@ pub trait Sample<Support> {
|
|||||||
|
|
||||||
/// `Sample`s that do not require keeping track of state.
|
/// `Sample`s that do not require keeping track of state.
|
||||||
///
|
///
|
||||||
/// Since no state is recored, each sample is (statistically)
|
/// Since no state is recorded, each sample is (statistically)
|
||||||
/// independent of all others, assuming the `Rng` used has this
|
/// independent of all others, assuming the `Rng` used has this
|
||||||
/// property.
|
/// property.
|
||||||
// XXX maybe having this separate is overkill (the only reason is to
|
// XXX maybe having this separate is overkill (the only reason is to
|
||||||
@ -84,7 +84,7 @@ pub struct Weighted<T> {
|
|||||||
/// is to be chosen: higher weight is more likely.
|
/// is to be chosen: higher weight is more likely.
|
||||||
///
|
///
|
||||||
/// The `Clone` restriction is a limitation of the `Sample` and
|
/// The `Clone` restriction is a limitation of the `Sample` and
|
||||||
/// `IndepedentSample` traits. Note that `&T` is (cheaply) `Clone` for
|
/// `IndependentSample` traits. Note that `&T` is (cheaply) `Clone` for
|
||||||
/// all `T`, as is `uint`, so one can store references or indices into
|
/// all `T`, as is `uint`, so one can store references or indices into
|
||||||
/// another vector.
|
/// another vector.
|
||||||
///
|
///
|
||||||
@ -92,7 +92,7 @@ pub struct Weighted<T> {
|
|||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::rand;
|
/// use std::rand;
|
||||||
/// use std::rand::distributions::{Weighted, WeightedChoice, IndepedentSample};
|
/// use std::rand::distributions::{Weighted, WeightedChoice, IndependentSample};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let wc = WeightedChoice::new(~[Weighted { weight: 2, item: 'a' },
|
/// let wc = WeightedChoice::new(~[Weighted { weight: 2, item: 'a' },
|
||||||
|
@ -119,7 +119,7 @@ fn next_u64(&mut self) -> u64 {
|
|||||||
/// Fill `dest` with random data.
|
/// Fill `dest` with random data.
|
||||||
///
|
///
|
||||||
/// This has a default implementation in terms of `next_u64` and
|
/// This has a default implementation in terms of `next_u64` and
|
||||||
/// `next_u32`, but should be overriden by implementations that
|
/// `next_u32`, but should be overridden by implementations that
|
||||||
/// offer a more efficient solution than just calling those
|
/// offer a more efficient solution than just calling those
|
||||||
/// methods repeatedly.
|
/// methods repeatedly.
|
||||||
///
|
///
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
use cast;
|
use cast;
|
||||||
use rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausibleIdleCallback,
|
use rt::rtio::{EventLoop, IoFactory, RemoteCallback, PausableIdleCallback,
|
||||||
Callback};
|
Callback};
|
||||||
use unstable::sync::Exclusive;
|
use unstable::sync::Exclusive;
|
||||||
use io::native;
|
use io::native;
|
||||||
@ -28,7 +28,7 @@ pub fn event_loop() -> ~EventLoop {
|
|||||||
|
|
||||||
struct BasicLoop {
|
struct BasicLoop {
|
||||||
work: ~[proc()], // pending work
|
work: ~[proc()], // pending work
|
||||||
idle: Option<*mut BasicPausible>, // only one is allowed
|
idle: Option<*mut BasicPausable>, // only one is allowed
|
||||||
remotes: ~[(uint, ~Callback)],
|
remotes: ~[(uint, ~Callback)],
|
||||||
next_remote: uint,
|
next_remote: uint,
|
||||||
messages: Exclusive<~[Message]>,
|
messages: Exclusive<~[Message]>,
|
||||||
@ -142,14 +142,14 @@ fn callback(&mut self, f: proc()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// XXX: Seems like a really weird requirement to have an event loop provide.
|
// XXX: Seems like a really weird requirement to have an event loop provide.
|
||||||
fn pausible_idle_callback(&mut self, cb: ~Callback) -> ~PausibleIdleCallback {
|
fn pausable_idle_callback(&mut self, cb: ~Callback) -> ~PausableIdleCallback {
|
||||||
let callback = ~BasicPausible::new(self, cb);
|
let callback = ~BasicPausable::new(self, cb);
|
||||||
rtassert!(self.idle.is_none());
|
rtassert!(self.idle.is_none());
|
||||||
unsafe {
|
unsafe {
|
||||||
let cb_ptr: &*mut BasicPausible = cast::transmute(&callback);
|
let cb_ptr: &*mut BasicPausable = cast::transmute(&callback);
|
||||||
self.idle = Some(*cb_ptr);
|
self.idle = Some(*cb_ptr);
|
||||||
}
|
}
|
||||||
return callback as ~PausibleIdleCallback;
|
return callback as ~PausableIdleCallback;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
|
fn remote_callback(&mut self, f: ~Callback) -> ~RemoteCallback {
|
||||||
@ -196,15 +196,15 @@ fn drop(&mut self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct BasicPausible {
|
struct BasicPausable {
|
||||||
eloop: *mut BasicLoop,
|
eloop: *mut BasicLoop,
|
||||||
work: ~Callback,
|
work: ~Callback,
|
||||||
active: bool,
|
active: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BasicPausible {
|
impl BasicPausable {
|
||||||
fn new(eloop: &mut BasicLoop, cb: ~Callback) -> BasicPausible {
|
fn new(eloop: &mut BasicLoop, cb: ~Callback) -> BasicPausable {
|
||||||
BasicPausible {
|
BasicPausable {
|
||||||
active: false,
|
active: false,
|
||||||
work: cb,
|
work: cb,
|
||||||
eloop: eloop,
|
eloop: eloop,
|
||||||
@ -212,7 +212,7 @@ fn new(eloop: &mut BasicLoop, cb: ~Callback) -> BasicPausible {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PausibleIdleCallback for BasicPausible {
|
impl PausableIdleCallback for BasicPausable {
|
||||||
fn pause(&mut self) {
|
fn pause(&mut self) {
|
||||||
self.active = false;
|
self.active = false;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ fn resume(&mut self) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for BasicPausible {
|
impl Drop for BasicPausable {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
unsafe {
|
unsafe {
|
||||||
(*self.eloop).idle = None;
|
(*self.eloop).idle = None;
|
||||||
|
@ -35,7 +35,7 @@ pub trait Callback {
|
|||||||
pub trait EventLoop {
|
pub trait EventLoop {
|
||||||
fn run(&mut self);
|
fn run(&mut self);
|
||||||
fn callback(&mut self, proc());
|
fn callback(&mut self, proc());
|
||||||
fn pausible_idle_callback(&mut self, ~Callback) -> ~PausibleIdleCallback;
|
fn pausable_idle_callback(&mut self, ~Callback) -> ~PausableIdleCallback;
|
||||||
fn remote_callback(&mut self, ~Callback) -> ~RemoteCallback;
|
fn remote_callback(&mut self, ~Callback) -> ~RemoteCallback;
|
||||||
|
|
||||||
/// The asynchronous I/O services. Not all event loops may provide one.
|
/// The asynchronous I/O services. Not all event loops may provide one.
|
||||||
@ -265,7 +265,7 @@ pub trait RtioTTY {
|
|||||||
fn isatty(&self) -> bool;
|
fn isatty(&self) -> bool;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait PausibleIdleCallback {
|
pub trait PausableIdleCallback {
|
||||||
fn pause(&mut self);
|
fn pause(&mut self);
|
||||||
fn resume(&mut self);
|
fn resume(&mut self);
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
use rt::deque;
|
use rt::deque;
|
||||||
use rt::local_ptr;
|
use rt::local_ptr;
|
||||||
use rt::local::Local;
|
use rt::local::Local;
|
||||||
use rt::rtio::{RemoteCallback, PausibleIdleCallback, Callback};
|
use rt::rtio::{RemoteCallback, PausableIdleCallback, Callback};
|
||||||
use borrow::{to_uint};
|
use borrow::{to_uint};
|
||||||
use rand::{XorShiftRng, Rng, Rand};
|
use rand::{XorShiftRng, Rng, Rand};
|
||||||
use iter::range;
|
use iter::range;
|
||||||
@ -75,8 +75,8 @@ pub struct Scheduler {
|
|||||||
friend_handle: Option<SchedHandle>,
|
friend_handle: Option<SchedHandle>,
|
||||||
/// A fast XorShift rng for scheduler use
|
/// A fast XorShift rng for scheduler use
|
||||||
rng: XorShiftRng,
|
rng: XorShiftRng,
|
||||||
/// A toggleable idle callback
|
/// A togglable idle callback
|
||||||
idle_callback: Option<~PausibleIdleCallback>,
|
idle_callback: Option<~PausableIdleCallback>,
|
||||||
/// A countdown that starts at a random value and is decremented
|
/// A countdown that starts at a random value and is decremented
|
||||||
/// every time a yield check is performed. When it hits 0 a task
|
/// every time a yield check is performed. When it hits 0 a task
|
||||||
/// will yield.
|
/// will yield.
|
||||||
@ -86,7 +86,7 @@ pub struct Scheduler {
|
|||||||
steal_for_yield: bool,
|
steal_for_yield: bool,
|
||||||
|
|
||||||
// n.b. currently destructors of an object are run in top-to-bottom in order
|
// n.b. currently destructors of an object are run in top-to-bottom in order
|
||||||
// of field declaration. Due to its nature, the pausible idle callback
|
// of field declaration. Due to its nature, the pausable idle callback
|
||||||
// must have some sort of handle to the event loop, so it needs to get
|
// must have some sort of handle to the event loop, so it needs to get
|
||||||
// destroyed before the event loop itself. For this reason, we destroy
|
// destroyed before the event loop itself. For this reason, we destroy
|
||||||
// the event loop last to ensure that any unsafe references to it are
|
// the event loop last to ensure that any unsafe references to it are
|
||||||
@ -170,7 +170,7 @@ pub fn bootstrap(mut ~self, task: ~Task) {
|
|||||||
|
|
||||||
// Build an Idle callback.
|
// Build an Idle callback.
|
||||||
let cb = ~SchedRunner as ~Callback;
|
let cb = ~SchedRunner as ~Callback;
|
||||||
self.idle_callback = Some(self.event_loop.pausible_idle_callback(cb));
|
self.idle_callback = Some(self.event_loop.pausable_idle_callback(cb));
|
||||||
|
|
||||||
// Initialize the TLS key.
|
// Initialize the TLS key.
|
||||||
local_ptr::init();
|
local_ptr::init();
|
||||||
|
@ -963,10 +963,9 @@ pub fn utf8_char_width(b: u8) -> uint {
|
|||||||
return UTF8_CHAR_WIDTH[b] as uint;
|
return UTF8_CHAR_WIDTH[b] as uint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Struct that contains a `char` and
|
/// Struct that contains a `char` and the index of the first byte of
|
||||||
/// the index of the first byte of the next `char` in a string.
|
/// the next `char` in a string. This can be used as a data structure
|
||||||
/// This is being used as a datastructure for iterating over
|
/// for iterating over the UTF-8 bytes of a string.
|
||||||
/// the utf8 bytes of a string.
|
|
||||||
pub struct CharRange {
|
pub struct CharRange {
|
||||||
/// Current `char`
|
/// Current `char`
|
||||||
ch: char,
|
ch: char,
|
||||||
@ -1570,7 +1569,8 @@ pub trait StrSlice<'a> {
|
|||||||
/// ```
|
/// ```
|
||||||
fn is_whitespace(&self) -> bool;
|
fn is_whitespace(&self) -> bool;
|
||||||
|
|
||||||
/// Returns true if the string contains only alphanumerics.
|
/// Returns true if the string contains only alphanumeric code
|
||||||
|
/// points.
|
||||||
///
|
///
|
||||||
/// Alphanumeric characters are determined by `char::is_alphanumeric`.
|
/// Alphanumeric characters are determined by `char::is_alphanumeric`.
|
||||||
///
|
///
|
||||||
@ -2518,7 +2518,7 @@ fn as_imm_buf<T>(&self, f: |*u8, uint| -> T) -> T {
|
|||||||
|
|
||||||
/// Methods for owned strings
|
/// Methods for owned strings
|
||||||
pub trait OwnedStr {
|
pub trait OwnedStr {
|
||||||
/// Appends a string slice to the back of a string, without overallocating
|
/// Appends a string slice to the back of a string, without overallocating.
|
||||||
fn push_str_no_overallocate(&mut self, rhs: &str);
|
fn push_str_no_overallocate(&mut self, rhs: &str);
|
||||||
|
|
||||||
/// Appends a string slice to the back of a string
|
/// Appends a string slice to the back of a string
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
//! lock.unlock();
|
//! lock.unlock();
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! // Use a normally initialied mutex
|
//! // Use a normally initialized mutex
|
||||||
//! let mut lock = Mutex::new();
|
//! let mut lock = Mutex::new();
|
||||||
//! unsafe {
|
//! unsafe {
|
||||||
//! lock.lock();
|
//! lock.lock();
|
||||||
|
@ -402,7 +402,7 @@ pub fn unzip<T, U, V: Iterator<(T, U)>>(mut iter: V) -> (~[T], ~[U]) {
|
|||||||
///
|
///
|
||||||
/// The Steinhaus–Johnson–Trotter algorithm is used.
|
/// The Steinhaus–Johnson–Trotter algorithm is used.
|
||||||
///
|
///
|
||||||
/// Generates even and odd permutations alternatingly.
|
/// Generates even and odd permutations alternately.
|
||||||
///
|
///
|
||||||
/// The last generated swap is always (0, 1), and it returns the
|
/// The last generated swap is always (0, 1), and it returns the
|
||||||
/// sequence to its initial order.
|
/// sequence to its initial order.
|
||||||
@ -480,7 +480,7 @@ fn new_pos(i: uint, s: Direction) -> uint {
|
|||||||
/// then each successive element is the vector with one
|
/// then each successive element is the vector with one
|
||||||
/// swap applied.
|
/// swap applied.
|
||||||
///
|
///
|
||||||
/// Generates even and odd permutations alternatingly.
|
/// Generates even and odd permutations alternately.
|
||||||
pub struct Permutations<T> {
|
pub struct Permutations<T> {
|
||||||
priv swaps: ElementSwaps,
|
priv swaps: ElementSwaps,
|
||||||
priv v: ~[T],
|
priv v: ~[T],
|
||||||
@ -940,7 +940,7 @@ pub trait ImmutableVector<'a, T> {
|
|||||||
fn tailn(&self, n: uint) -> &'a [T];
|
fn tailn(&self, n: uint) -> &'a [T];
|
||||||
/// Returns all but the last element of a vector
|
/// Returns all but the last element of a vector
|
||||||
fn init(&self) -> &'a [T];
|
fn init(&self) -> &'a [T];
|
||||||
/// Returns all but the last `n' elemnts of a vector
|
/// Returns all but the last `n' elements of a vector
|
||||||
fn initn(&self, n: uint) -> &'a [T];
|
fn initn(&self, n: uint) -> &'a [T];
|
||||||
/// Returns the last element of a vector, failing if the vector is empty.
|
/// Returns the last element of a vector, failing if the vector is empty.
|
||||||
fn last(&self) -> &'a T;
|
fn last(&self) -> &'a T;
|
||||||
@ -958,9 +958,10 @@ pub trait ImmutableVector<'a, T> {
|
|||||||
/**
|
/**
|
||||||
* Binary search a sorted vector with a comparator function.
|
* Binary search a sorted vector with a comparator function.
|
||||||
*
|
*
|
||||||
* The comparator should implement an order consistent with the sort
|
* The comparator function should implement an order consistent
|
||||||
* order of the underlying vector, returning an order code that indicates
|
* with the sort order of the underlying vector, returning an
|
||||||
* whether its argument is `Less`, `Equal` or `Greater` the desired target.
|
* order code that indicates whether its argument is `Less`,
|
||||||
|
* `Equal` or `Greater` the desired target.
|
||||||
*
|
*
|
||||||
* Returns the index where the comparator returned `Equal`, or `None` if
|
* Returns the index where the comparator returned `Equal`, or `None` if
|
||||||
* not found.
|
* not found.
|
||||||
@ -1436,14 +1437,14 @@ pub trait OwnedVector<T> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Expands a vector in place, initializing the new elements to the result of
|
* Expands a vector in place, initializing the new elements to the result of
|
||||||
* a function
|
* a function.
|
||||||
*
|
*
|
||||||
* Function `init_op` is called `n` times with the values [0..`n`)
|
* Function `init_op` is called `n` times with the values [0..`n`)
|
||||||
*
|
*
|
||||||
* # Arguments
|
* # Arguments
|
||||||
*
|
*
|
||||||
* * n - The number of elements to add
|
* * n - The number of elements to add
|
||||||
* * init_op - A function to call to retreive each appended element's
|
* * init_op - A function to call to retrieve each appended element's
|
||||||
* value
|
* value
|
||||||
*/
|
*/
|
||||||
fn grow_fn(&mut self, n: uint, op: |uint| -> T);
|
fn grow_fn(&mut self, n: uint, op: |uint| -> T);
|
||||||
|
Loading…
Reference in New Issue
Block a user