2014-05-01 20:06:59 -05:00
|
|
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
|
|
|
|
// file at the top-level directory of this distribution and at
|
|
|
|
// http://rust-lang.org/COPYRIGHT.
|
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
|
|
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
|
|
|
// option. This file may not be copied, modified, or distributed
|
|
|
|
// except according to those terms.
|
|
|
|
|
|
|
|
//! The core prelude
|
|
|
|
//!
|
2014-05-16 15:22:08 -05:00
|
|
|
//! This module is intended for users of libcore which do not link to libstd as
|
|
|
|
//! well. This module is not imported by default, but using the entire contents
|
|
|
|
//! of this module will provide all of the useful traits and types in libcore
|
|
|
|
//! that one would expect from the standard library as well.
|
|
|
|
//!
|
|
|
|
//! There is no method to automatically inject this prelude, and this prelude is
|
|
|
|
//! a subset of the standard library's prelude.
|
|
|
|
//!
|
|
|
|
//! # Example
|
|
|
|
//!
|
|
|
|
//! ```ignore
|
|
|
|
//! # fn main() {
|
|
|
|
//! #![feature(globs)]
|
|
|
|
//!
|
|
|
|
//! use core::prelude::*;
|
|
|
|
//! # }
|
|
|
|
//! ```
|
2014-05-01 20:06:59 -05:00
|
|
|
|
|
|
|
// Reexported core operators
|
2014-08-05 18:40:04 -05:00
|
|
|
pub use kinds::{Copy, Send, Sized, Sync};
|
2014-05-01 20:06:59 -05:00
|
|
|
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
|
|
|
|
pub use ops::{BitAnd, BitOr, BitXor};
|
|
|
|
pub use ops::{Drop, Deref, DerefMut};
|
2014-07-03 16:32:41 -05:00
|
|
|
pub use ops::{Shl, Shr};
|
|
|
|
pub use ops::{Index, IndexMut};
|
2014-10-04 17:59:10 -05:00
|
|
|
pub use ops::{Slice, SliceMut};
|
2014-05-29 00:26:56 -05:00
|
|
|
pub use ops::{Fn, FnMut, FnOnce};
|
2014-05-01 20:06:59 -05:00
|
|
|
|
|
|
|
// Reexported functions
|
2014-11-06 11:32:37 -06:00
|
|
|
pub use iter::range;
|
2014-05-01 20:06:59 -05:00
|
|
|
pub use mem::drop;
|
2014-11-14 22:52:00 -06:00
|
|
|
pub use str::from_str;
|
2014-05-01 20:06:59 -05:00
|
|
|
|
|
|
|
// Reexported types and traits
|
|
|
|
|
|
|
|
pub use char::Char;
|
|
|
|
pub use clone::Clone;
|
2014-05-31 12:43:52 -05:00
|
|
|
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
|
2014-11-06 02:05:53 -06:00
|
|
|
pub use cmp::{Ordering, Equiv};
|
|
|
|
pub use cmp::Ordering::{Less, Equal, Greater};
|
2014-11-06 11:32:37 -06:00
|
|
|
pub use iter::{FromIterator, Extend, IteratorExt};
|
|
|
|
pub use iter::{Iterator, DoubleEndedIterator, DoubleEndedIteratorExt, RandomAccessIterator};
|
|
|
|
pub use iter::{IteratorCloneExt, CloneIteratorExt};
|
|
|
|
pub use iter::{IteratorOrdExt, MutableDoubleEndedIterator, ExactSizeIterator};
|
2014-11-12 07:02:42 -06:00
|
|
|
pub use num::{ToPrimitive, FromPrimitive};
|
2014-11-06 02:05:53 -06:00
|
|
|
pub use option::Option;
|
|
|
|
pub use option::Option::{Some, None};
|
2014-05-01 20:06:59 -05:00
|
|
|
pub use ptr::RawPtr;
|
2014-11-06 02:05:53 -06:00
|
|
|
pub use result::Result;
|
|
|
|
pub use result::Result::{Ok, Err};
|
std: Stabilize the std::str module
This commit starts out by consolidating all `str` extension traits into one
`StrExt` trait to be included in the prelude. This means that
`UnicodeStrPrelude`, `StrPrelude`, and `StrAllocating` have all been merged into
one `StrExt` exported by the standard library. Some functionality is currently
duplicated with the `StrExt` present in libcore.
This commit also currently avoids any methods which require any form of pattern
to operate. These functions will be stabilized via a separate RFC.
Next, stability of methods and structures are as follows:
Stable
* from_utf8_unchecked
* CowString - after moving to std::string
* StrExt::as_bytes
* StrExt::as_ptr
* StrExt::bytes/Bytes - also made a struct instead of a typedef
* StrExt::char_indices/CharIndices - CharOffsets was renamed
* StrExt::chars/Chars
* StrExt::is_empty
* StrExt::len
* StrExt::lines/Lines
* StrExt::lines_any/LinesAny
* StrExt::slice_unchecked
* StrExt::trim
* StrExt::trim_left
* StrExt::trim_right
* StrExt::words/Words - also made a struct instead of a typedef
Unstable
* from_utf8 - the error type was changed to a `Result`, but the error type has
yet to prove itself
* from_c_str - this function will be handled by the c_str RFC
* FromStr - this trait will have an associated error type eventually
* StrExt::escape_default - needs iterators at least, unsure if it should make
the cut
* StrExt::escape_unicode - needs iterators at least, unsure if it should make
the cut
* StrExt::slice_chars - this function has yet to prove itself
* StrExt::slice_shift_char - awaiting conventions about slicing and shifting
* StrExt::graphemes/Graphemes - this functionality may only be in libunicode
* StrExt::grapheme_indices/GraphemeIndices - this functionality may only be in
libunicode
* StrExt::width - this functionality may only be in libunicode
* StrExt::utf16_units - this functionality may only be in libunicode
* StrExt::nfd_chars - this functionality may only be in libunicode
* StrExt::nfkd_chars - this functionality may only be in libunicode
* StrExt::nfc_chars - this functionality may only be in libunicode
* StrExt::nfkc_chars - this functionality may only be in libunicode
* StrExt::is_char_boundary - naming is uncertain with container conventions
* StrExt::char_range_at - naming is uncertain with container conventions
* StrExt::char_range_at_reverse - naming is uncertain with container conventions
* StrExt::char_at - naming is uncertain with container conventions
* StrExt::char_at_reverse - naming is uncertain with container conventions
* StrVector::concat - this functionality may be replaced with iterators, but
it's not certain at this time
* StrVector::connect - as with concat, may be deprecated in favor of iterators
Deprecated
* StrAllocating and UnicodeStrPrelude have been merged into StrExit
* eq_slice - compiler implementation detail
* from_str - use the inherent parse() method
* is_utf8 - call from_utf8 instead
* replace - call the method instead
* truncate_utf16_at_nul - this is an implementation detail of windows and does
not need to be exposed.
* utf8_char_width - moved to libunicode
* utf16_items - moved to libunicode
* is_utf16 - moved to libunicode
* Utf16Items - moved to libunicode
* Utf16Item - moved to libunicode
* Utf16Encoder - moved to libunicode
* AnyLines - renamed to LinesAny and made a struct
* SendStr - use CowString<'static> instead
* str::raw - all functionality is deprecated
* StrExt::into_string - call to_string() instead
* StrExt::repeat - use iterators instead
* StrExt::char_len - use .chars().count() instead
* StrExt::is_alphanumeric - use .chars().all(..)
* StrExt::is_whitespace - use .chars().all(..)
Pending deprecation -- while slicing syntax is being worked out, these methods
are all #[unstable]
* Str - while currently used for generic programming, this trait will be
replaced with one of [], deref coercions, or a generic conversion trait.
* StrExt::slice - use slicing syntax instead
* StrExt::slice_to - use slicing syntax instead
* StrExt::slice_from - use slicing syntax instead
* StrExt::lev_distance - deprecated with no replacement
Awaiting stabilization due to patterns and/or matching
* StrExt::contains
* StrExt::contains_char
* StrExt::split
* StrExt::splitn
* StrExt::split_terminator
* StrExt::rsplitn
* StrExt::match_indices
* StrExt::split_str
* StrExt::starts_with
* StrExt::ends_with
* StrExt::trim_chars
* StrExt::trim_left_chars
* StrExt::trim_right_chars
* StrExt::find
* StrExt::rfind
* StrExt::find_str
* StrExt::subslice_offset
2014-12-10 11:02:31 -06:00
|
|
|
pub use str::{Str, StrExt};
|
2014-05-01 20:06:59 -05:00
|
|
|
pub use tuple::{Tuple1, Tuple2, Tuple3, Tuple4};
|
|
|
|
pub use tuple::{Tuple5, Tuple6, Tuple7, Tuple8};
|
|
|
|
pub use tuple::{Tuple9, Tuple10, Tuple11, Tuple12};
|
2014-12-11 11:44:17 -06:00
|
|
|
pub use slice::{PartialEqSliceExt, OrdSliceExt};
|
|
|
|
pub use slice::{AsSlice, SliceExt};
|