rust/src/libcore/core.rs

99 lines
2.8 KiB
Rust
Raw Normal View History

// Top-level, visible-everywhere definitions.
// Export various ubiquitous types, constructors, methods.
2012-02-21 11:23:01 -06:00
import option::{some, none};
import option = option::option;
2012-08-14 15:38:35 -05:00
import Path = path::Path;
import tuple::{TupleOps, ExtendedTupleOps};
2012-08-14 18:54:13 -05:00
import str::{StrSlice, UniqueStr};
import vec::{ConstVector, CopyableVector, ImmutableVector};
import vec::{ImmutableCopyableVector};
2012-08-14 18:54:13 -05:00
import iter::{BaseIter, ExtendedIter, CopyableIter, Times, TimesIx};
import num::Num;
2012-08-14 18:54:13 -05:00
import ptr::Ptr;
import to_str::ToStr;
2012-03-17 20:02:45 -05:00
2012-08-14 15:38:35 -05:00
export Path, option, some, none, unreachable;
2012-03-16 19:35:38 -05:00
export extensions;
// The following exports are the extension impls for numeric types
2012-08-14 18:54:13 -05:00
export Num, Times, TimesIx;
// The following exports are the common traits
2012-08-14 18:54:13 -05:00
export StrSlice, UniqueStr;
export ConstVector, CopyableVector, ImmutableVector;
export ImmutableCopyableVector, IterTraitExtensions;
export BaseIter, CopyableIter, ExtendedIter;
export TupleOps, ExtendedTupleOps;
2012-08-14 18:54:13 -05:00
export Ptr;
export ToStr;
// The following exports are the core operators and kinds
// The compiler has special knowlege of these so we must not duplicate them
// when compiling for testing
#[cfg(notest)]
import ops::{const, copy, send, owned};
#[cfg(notest)]
2012-07-28 16:14:17 -05:00
import ops::{add, sub, mul, div, modulo, neg, bitand, bitor, bitxor};
#[cfg(notest)]
2012-07-28 16:14:17 -05:00
import ops::{shl, shr, index};
#[cfg(notest)]
export const, copy, send, owned;
#[cfg(notest)]
2012-07-28 16:14:17 -05:00
export add, sub, mul, div, modulo, neg, bitand, bitor, bitxor;
#[cfg(notest)]
export shl, shr, index;
#[cfg(test)]
use coreops(name = "core", vers = "0.3");
#[cfg(test)]
import coreops::ops::{const, copy, send, owned};
#[cfg(test)]
import coreops::ops::{add, sub, mul, div, modulo, neg, bitand, bitor, bitxor};
#[cfg(test)]
import coreops::ops::{shl, shr, index};
// Export the log levels as global constants. Higher levels mean
// more-verbosity. Error is the bottom level, default logging level is
// warn-and-below.
export error, warn, info, debug;
2012-01-24 02:54:17 -06:00
/// The error log level
const error : u32 = 0_u32;
/// The warning log level
const warn : u32 = 1_u32;
/// The info log level
const info : u32 = 2_u32;
/// The debug log level
const debug : u32 = 3_u32;
// A curious inner-module that's not exported that contains the binding
// 'core' so that macro-expanded references to core::error and such
// can be resolved within libcore.
mod core {
const error : u32 = 0_u32;
const warn : u32 = 1_u32;
const info : u32 = 2_u32;
const debug : u32 = 3_u32;
2012-01-17 18:45:22 -06:00
}
// Similar to above. Some magic to make core testable.
#[cfg(test)]
mod std {
2012-07-11 11:09:08 -05:00
use std(vers = "0.3");
2012-01-17 18:45:22 -06:00
import std::test;
}
/**
* A standard function to use to indicate unreachable code. Because the
* function is guaranteed to fail typestate will correctly identify
* any code paths following the appearance of this function as unreachable.
*/
fn unreachable() -> ! {
fail ~"Internal error: entered unreachable code";
}