De-export logging, to_str, to_bytes, from_str, util. Part of #3583.
This commit is contained in:
@@ -188,7 +188,6 @@ mod hash;
|
|||||||
mod either;
|
mod either;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod iter;
|
mod iter;
|
||||||
#[legacy_exports]
|
|
||||||
mod logging;
|
mod logging;
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod option;
|
mod option;
|
||||||
@@ -201,13 +200,9 @@ mod option_iter {
|
|||||||
}
|
}
|
||||||
#[legacy_exports]
|
#[legacy_exports]
|
||||||
mod result;
|
mod result;
|
||||||
#[legacy_exports]
|
|
||||||
mod to_str;
|
mod to_str;
|
||||||
#[legacy_exports]
|
|
||||||
mod to_bytes;
|
mod to_bytes;
|
||||||
#[legacy_exports]
|
|
||||||
mod from_str;
|
mod from_str;
|
||||||
#[legacy_exports]
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
// Data structure modules
|
// Data structure modules
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
use option::Option;
|
use option::Option;
|
||||||
|
|
||||||
trait FromStr {
|
pub trait FromStr {
|
||||||
static fn from_str(s: &str) -> Option<self>;
|
static fn from_str(s: &str) -> Option<self>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use cast::transmute;
|
|||||||
|
|
||||||
#[nolink]
|
#[nolink]
|
||||||
extern mod rustrt {
|
extern mod rustrt {
|
||||||
#[legacy_exports];
|
|
||||||
fn rust_log_console_on();
|
fn rust_log_console_on();
|
||||||
fn rust_log_console_off();
|
fn rust_log_console_off();
|
||||||
fn rust_log_str(level: u32, string: *libc::c_char, size: libc::size_t);
|
fn rust_log_str(level: u32, string: *libc::c_char, size: libc::size_t);
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ The `ToBytes` and `IterBytes` traits
|
|||||||
|
|
||||||
use io::Writer;
|
use io::Writer;
|
||||||
|
|
||||||
type Cb = fn(buf: &[const u8]) -> bool;
|
pub type Cb = fn(buf: &[const u8]) -> bool;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A trait to implement in order to make a type hashable;
|
* A trait to implement in order to make a type hashable;
|
||||||
@@ -19,7 +19,7 @@ type Cb = fn(buf: &[const u8]) -> bool;
|
|||||||
* modified when default methods and trait inheritence are
|
* modified when default methods and trait inheritence are
|
||||||
* completed.
|
* completed.
|
||||||
*/
|
*/
|
||||||
trait IterBytes {
|
pub trait IterBytes {
|
||||||
/**
|
/**
|
||||||
* Call the provided callback `f` one or more times with
|
* Call the provided callback `f` one or more times with
|
||||||
* byte-slices that should be used when computing a hash
|
* byte-slices that should be used when computing a hash
|
||||||
@@ -211,7 +211,7 @@ impl<A: IterBytes> @[A]: IterBytes {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_2<A: IterBytes, B: IterBytes>(a: &A, b: &B,
|
pub pure fn iter_bytes_2<A: IterBytes, B: IterBytes>(a: &A, b: &B,
|
||||||
lsb0: bool, z: Cb) {
|
lsb0: bool, z: Cb) {
|
||||||
let mut flag = true;
|
let mut flag = true;
|
||||||
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
a.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
@@ -219,7 +219,7 @@ pure fn iter_bytes_2<A: IterBytes, B: IterBytes>(a: &A, b: &B,
|
|||||||
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
b.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_3<A: IterBytes,
|
pub pure fn iter_bytes_3<A: IterBytes,
|
||||||
B: IterBytes,
|
B: IterBytes,
|
||||||
C: IterBytes>(a: &A, b: &B, c: &C,
|
C: IterBytes>(a: &A, b: &B, c: &C,
|
||||||
lsb0: bool, z: Cb) {
|
lsb0: bool, z: Cb) {
|
||||||
@@ -231,7 +231,7 @@ pure fn iter_bytes_3<A: IterBytes,
|
|||||||
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
c.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_4<A: IterBytes,
|
pub pure fn iter_bytes_4<A: IterBytes,
|
||||||
B: IterBytes,
|
B: IterBytes,
|
||||||
C: IterBytes,
|
C: IterBytes,
|
||||||
D: IterBytes>(a: &A, b: &B, c: &C,
|
D: IterBytes>(a: &A, b: &B, c: &C,
|
||||||
@@ -247,7 +247,7 @@ pure fn iter_bytes_4<A: IterBytes,
|
|||||||
d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
d.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_5<A: IterBytes,
|
pub pure fn iter_bytes_5<A: IterBytes,
|
||||||
B: IterBytes,
|
B: IterBytes,
|
||||||
C: IterBytes,
|
C: IterBytes,
|
||||||
D: IterBytes,
|
D: IterBytes,
|
||||||
@@ -266,7 +266,7 @@ pure fn iter_bytes_5<A: IterBytes,
|
|||||||
e.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
e.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_6<A: IterBytes,
|
pub pure fn iter_bytes_6<A: IterBytes,
|
||||||
B: IterBytes,
|
B: IterBytes,
|
||||||
C: IterBytes,
|
C: IterBytes,
|
||||||
D: IterBytes,
|
D: IterBytes,
|
||||||
@@ -288,7 +288,7 @@ pure fn iter_bytes_6<A: IterBytes,
|
|||||||
f.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
f.iter_bytes(lsb0, |bytes| {flag = z(bytes); flag});
|
||||||
}
|
}
|
||||||
|
|
||||||
pure fn iter_bytes_7<A: IterBytes,
|
pub pure fn iter_bytes_7<A: IterBytes,
|
||||||
B: IterBytes,
|
B: IterBytes,
|
||||||
C: IterBytes,
|
C: IterBytes,
|
||||||
D: IterBytes,
|
D: IterBytes,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ The `ToStr` trait for converting to strings
|
|||||||
#[forbid(deprecated_mode)];
|
#[forbid(deprecated_mode)];
|
||||||
#[forbid(deprecated_pattern)];
|
#[forbid(deprecated_pattern)];
|
||||||
|
|
||||||
trait ToStr { fn to_str() -> ~str; }
|
pub trait ToStr { fn to_str() -> ~str; }
|
||||||
|
|
||||||
impl int: ToStr {
|
impl int: ToStr {
|
||||||
fn to_str() -> ~str { int::str(self) }
|
fn to_str() -> ~str { int::str(self) }
|
||||||
@@ -101,7 +101,6 @@ impl<A: ToStr> ~A: ToStr {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
#[allow(non_implicitly_copyable_typarams)]
|
#[allow(non_implicitly_copyable_typarams)]
|
||||||
mod tests {
|
mod tests {
|
||||||
#[legacy_exports];
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_simple_types() {
|
fn test_simple_types() {
|
||||||
assert 1.to_str() == ~"1";
|
assert 1.to_str() == ~"1";
|
||||||
|
|||||||
@@ -12,16 +12,16 @@ use cmp::Eq;
|
|||||||
|
|
||||||
/// The identity function.
|
/// The identity function.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn id<T>(+x: T) -> T { move x }
|
pub pure fn id<T>(+x: T) -> T { move x }
|
||||||
|
|
||||||
/// Ignores a value.
|
/// Ignores a value.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pure fn ignore<T>(+_x: T) { }
|
pub pure fn ignore<T>(+_x: T) { }
|
||||||
|
|
||||||
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
|
/// Sets `*ptr` to `new_value`, invokes `op()`, and then restores the
|
||||||
/// original value of `*ptr`.
|
/// original value of `*ptr`.
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn with<T: Copy, R>(
|
pub fn with<T: Copy, R>(
|
||||||
ptr: &mut T,
|
ptr: &mut T,
|
||||||
+new_value: T,
|
+new_value: T,
|
||||||
op: &fn() -> R) -> R
|
op: &fn() -> R) -> R
|
||||||
@@ -41,7 +41,7 @@ fn with<T: Copy, R>(
|
|||||||
* deinitialising or copying either one.
|
* deinitialising or copying either one.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn swap<T>(x: &mut T, y: &mut T) {
|
pub fn swap<T>(x: &mut T, y: &mut T) {
|
||||||
*x <-> *y;
|
*x <-> *y;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,19 +50,19 @@ fn swap<T>(x: &mut T, y: &mut T) {
|
|||||||
* value, without deinitialising or copying either one.
|
* value, without deinitialising or copying either one.
|
||||||
*/
|
*/
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn replace<T>(dest: &mut T, +src: T) -> T {
|
pub fn replace<T>(dest: &mut T, +src: T) -> T {
|
||||||
let mut tmp <- src;
|
let mut tmp <- src;
|
||||||
swap(dest, &mut tmp);
|
swap(dest, &mut tmp);
|
||||||
move tmp
|
move tmp
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A non-copyable dummy type.
|
/// A non-copyable dummy type.
|
||||||
struct NonCopyable {
|
pub struct NonCopyable {
|
||||||
i: (),
|
i: (),
|
||||||
drop { }
|
drop { }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }
|
pub fn NonCopyable() -> NonCopyable { NonCopyable { i: () } }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A utility function for indicating unreachable code. It will fail if
|
A utility function for indicating unreachable code. It will fail if
|
||||||
@@ -88,7 +88,7 @@ fn choose_weighted_item(v: &[Item]) -> Item {
|
|||||||
~~~
|
~~~
|
||||||
|
|
||||||
*/
|
*/
|
||||||
fn unreachable() -> ! {
|
pub fn unreachable() -> ! {
|
||||||
fail ~"internal error: entered unreachable code";
|
fail ~"internal error: entered unreachable code";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user