Browse Source

libstd prelude, take 2

pull/10/head
Fenrir 8 years ago
parent
commit
fdbf10cd89
  1. 61
      src/lib.rs
  2. 4
      src/services/fs.rs
  3. 0
      src/system/ascii.rs
  4. 0
      src/system/error.rs
  5. 27
      src/system/ffi/c_str.rs
  6. 0
      src/system/ffi/mod.rs
  7. 23
      src/system/ffi/os_str.rs
  8. 15
      src/system/io/buffered.rs
  9. 9
      src/system/io/cursor.rs
  10. 11
      src/system/io/error.rs
  11. 12
      src/system/io/impls.rs
  12. 16
      src/system/io/mod.rs
  13. 0
      src/system/io/prelude.rs
  14. 2
      src/system/io/util.rs
  15. 0
      src/system/memchr.rs
  16. 9
      src/system/mod.rs
  17. 0
      src/system/panicking.rs
  18. 22
      src/system/path.rs
  19. 9
      src/system/rt.rs
  20. 0
      src/system/sys/mod.rs
  21. 22
      src/system/sys/wtf8.rs

61
src/lib.rs

@ -1,8 +1,13 @@ @@ -1,8 +1,13 @@
#![feature(alloc)]
#![feature(allow_internal_unstable)]
#![feature(collections)]
#![feature(core_intrinsics)]
#![feature(char_escape_debug)]
#![feature(int_error_internals)]
#![feature(lang_items)]
#![feature(macro_reexport)]
#![feature(prelude_import)]
#![feature(slice_concat_ext)]
#![feature(slice_patterns)]
#![feature(str_internals)]
#![feature(try_from)]
@ -15,26 +20,60 @@ @@ -15,26 +20,60 @@
extern crate alloc;
extern crate alloc_system;
#[macro_use] extern crate collections;
#[macro_reexport(format, vec)]
#[macro_use]
extern crate collections;
extern crate rustc_unicode;
extern crate ctru_sys as libctru;
#[prelude_import]
#[allow(unused)]
use prelude::*;
pub mod std {
pub use core::{any, cell, clone, cmp, convert, default, hash, i16, i32, i64, i8, isize, iter,
marker, mem, ops, option, ptr, result, u16, u32, u64, u8, usize, intrinsics};
pub use rustc_unicode::char;
pub use alloc::{arc, rc};
pub use collections::{borrow, boxed, fmt, slice, str, string, vec};
pub use system::{error, io, memchr, ascii, ffi, path};
pub mod collections {
pub use collections::{binary_heap, btree_map, btree_set, linked_list, vec_deque,
BinaryHeap, LinkedList, VecDeque, String, Vec, BTreeMap, BTreeSet};
}
}
pub mod prelude {
pub use std;
pub use std::marker::{Copy, Send, Sized, Sync};
pub use std::ops::{Drop, Fn, FnMut, FnOnce};
pub use std::mem::drop;
pub use std::boxed::Box;
pub use std::borrow::ToOwned;
pub use std::clone::Clone;
pub use std::cmp::{PartialEq, PartialOrd, Eq, Ord};
pub use std::convert::{AsRef, AsMut, Into, From};
pub use std::default::Default;
pub use std::iter::{Iterator, Extend, IntoIterator};
pub use std::iter::{DoubleEndedIterator, ExactSizeIterator};
pub use std::option::Option::{self, Some, None};
pub use std::result::Result::{self, Ok, Err};
pub use std::slice::SliceConcatExt;
pub use std::string::{String, ToString};
pub use std::vec::Vec;
pub use std::fmt::Write;
}
pub use std::{fmt, boxed, vec};
pub mod console;
pub mod srv;
pub mod gfx;
pub mod services;
pub mod sdmc;
pub mod ascii;
pub mod error;
pub mod ffi;
pub mod io;
pub mod memchr;
pub mod panic;
pub mod path;
mod sys;
pub mod system;
pub use srv::Srv;
pub use gfx::Gfx;

4
src/services/fs.rs

@ -11,8 +11,8 @@ use core::mem; @@ -11,8 +11,8 @@ use core::mem;
use alloc::arc::Arc;
use collections::Vec;
use path::{Path, PathBuf};
use ffi::OsString;
use std::path::{Path, PathBuf};
use std::ffi::OsString;
use libctru::services::fs::*;

0
src/ascii.rs → src/system/ascii.rs

0
src/error.rs → src/system/error.rs

27
src/ffi/c_str.rs → src/system/ffi/c_str.rs

@ -8,22 +8,19 @@ @@ -8,22 +8,19 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use ascii;
use collections::borrow::{Cow, Borrow, ToOwned};
use core::cmp::Ordering;
use error::Error;
use core::fmt::{self, Write};
use io;
use std::ascii;
use std::borrow::{Cow, Borrow};
use std::cmp::Ordering;
use std::error::Error;
use std::fmt::{self, Write};
use std::io;
use libctru::libc::{self, c_char};
use core::mem;
use memchr;
use core::ops;
use core::ptr;
use core::slice;
use core::str::{self, Utf8Error};
use alloc::boxed::Box;
use collections::Vec;
use collections::String;
use std::mem;
use system::memchr;
use std::ops;
use std::ptr;
use std::slice;
use std::str::{self, Utf8Error};
/// A type representing an owned C-compatible string
///

0
src/ffi/mod.rs → src/system/ffi/mod.rs

23
src/ffi/os_str.rs → src/system/ffi/os_str.rs

@ -8,19 +8,16 @@ @@ -8,19 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use collections::borrow::{Borrow, Cow, ToOwned};
use core::fmt::{self, Debug};
use core::mem;
use collections::String;
use core::ops;
use core::cmp;
use core::hash::{Hash, Hasher};
use collections::Vec;
use sys::wtf8::{Wtf8, Wtf8Buf};
use sys::{AsInner, IntoInner, FromInner};
pub use sys::wtf8::EncodeWide;
use std::borrow::{Borrow, Cow};
use std::fmt::{self, Debug};
use std::mem;
use std::ops;
use std::cmp;
use std::hash::{Hash, Hasher};
use system::sys::wtf8::{Wtf8, Wtf8Buf};
use system::sys::{AsInner, IntoInner, FromInner};
pub use system::sys::wtf8::EncodeWide;
/// A type that can represent owned, mutable platform-native strings, but is
/// cheaply inter-convertible with Rust strings.

15
src/io/buffered.rs → src/system/io/buffered.rs

@ -10,16 +10,13 @@ @@ -10,16 +10,13 @@
//! Buffering wrappers for I/O traits
use io::prelude::*;
use std::io::prelude::*;
use core::cmp;
use error;
use core::fmt;
use io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
use memchr;
use collections::boxed::Box;
use collections::Vec;
use std::cmp;
use std::error;
use std::fmt;
use std::io::{self, DEFAULT_BUF_SIZE, Error, ErrorKind, SeekFrom};
use std::memchr;
/// The `BufReader` struct adds buffering to any reader.
///

9
src/io/cursor.rs → src/system/io/cursor.rs

@ -8,13 +8,10 @@ @@ -8,13 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use io::prelude::*;
use std::io::prelude::*;
use core::cmp;
use io::{self, SeekFrom, Error, ErrorKind};
use collections::boxed::Box;
use collections::Vec;
use std::cmp;
use std::io::{self, SeekFrom, Error, ErrorKind};
/// A `Cursor` wraps another type and provides it with a
/// [`Seek`](trait.Seek.html) implementation.

11
src/io/error.rs → src/system/io/error.rs

@ -8,13 +8,10 @@ @@ -8,13 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use alloc::boxed::Box;
use core::convert::Into;
use core::fmt;
use core::marker::{Send, Sync};
use core::option::Option::{self, Some, None};
use core::result;
use error;
use std::error;
use std::fmt;
use std::result;
/// A specialized [`Result`](../result/enum.Result.html) type for I/O
/// operations.

12
src/io/impls.rs → src/system/io/impls.rs

@ -8,14 +8,10 @@ @@ -8,14 +8,10 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use core::cmp;
use io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind};
use core::fmt;
use core::mem;
use collections::boxed::Box;
use collections::Vec;
use collections::String;
use std::cmp;
use std::io::{self, SeekFrom, Read, Write, Seek, BufRead, Error, ErrorKind};
use std::fmt;
use std::mem;
// =============================================================================
// Forwarding implementations

16
src/io/mod.rs → src/system/io/mod.rs

@ -247,17 +247,13 @@ @@ -247,17 +247,13 @@
//! contract. The implementation of many of these functions are subject to change over
//! time and may call fewer or more syscalls/library functions.
use core::cmp;
use std::cmp;
use rustc_unicode::str as core_str;
use error as std_error;
use core::fmt;
use core::result;
use core::str;
use memchr;
use collections::Vec;
use collections::String;
use std::error as std_error;
use std::fmt;
use std::result;
use std::str;
use std::memchr;
pub use self::buffered::{BufReader, BufWriter, LineWriter};
pub use self::buffered::IntoInnerError;

0
src/io/prelude.rs → src/system/io/prelude.rs

2
src/io/util.rs → src/system/io/util.rs

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
#![allow(missing_copy_implementations)]
use io::{self, Read, Write, ErrorKind, BufRead};
use std::io::{self, Read, Write, ErrorKind, BufRead};
/// Copies the entire contents of a reader into a writer.
///

0
src/memchr.rs → src/system/memchr.rs

9
src/system/mod.rs

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
pub mod ascii;
pub mod error;
pub mod ffi;
pub mod io;
pub mod memchr;
pub mod panicking;
pub mod path;
pub mod rt;
mod sys;

0
src/panic.rs → src/system/panicking.rs

22
src/path.rs → src/system/path.rs

@ -97,21 +97,19 @@ @@ -97,21 +97,19 @@
//! normalization is possible to build on top of the components APIs,
//! and will be included in this library in the near future.
use ascii::*;
use collections::borrow::{Borrow, ToOwned, Cow};
use core::cmp;
use std::ascii::*;
use std::borrow::{Borrow, ToOwned, Cow};
use std::cmp;
//use error::Error;
use core::fmt;
use std::fmt;
//use fs;
use core::hash::{Hash, Hasher};
use std::hash::{Hash, Hasher};
//use io;
use core::iter;
use core::mem;
use core::ops::{self, Deref};
use collections::String;
use collections::Vec;
use std::mem;
use std::ops::{self, Deref};
use std::iter;
use ffi::{OsStr, OsString};
use std::ffi::{OsStr, OsString};
use self::platform::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
@ -134,7 +132,7 @@ use self::platform::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; @@ -134,7 +132,7 @@ use self::platform::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix};
mod platform {
use super::Prefix;
use ffi::OsStr;
use std::ffi::OsStr;
#[inline]
pub fn is_sep_byte(b: u8) -> bool {

9
src/system/rt.rs

@ -0,0 +1,9 @@ @@ -0,0 +1,9 @@
use std::mem;
//TODO: Handle argc/argv arguments
#[lang = "start"]
#[allow(unused_variables)]
fn lang_start(main: *const u8, argc: isize, argv: *const *const u8) -> isize {
unsafe { mem::transmute::<_, fn()>(main)(); }
0
}

0
src/sys/mod.rs → src/system/sys/mod.rs

22
src/sys/wtf8.rs → src/system/sys/wtf8.rs

@ -27,19 +27,17 @@ @@ -27,19 +27,17 @@
use core::str::next_code_point;
use ascii::*;
use collections::borrow::Cow;
use std::ascii::*;
use std::borrow::Cow;
use rustc_unicode::char;
use core::fmt;
use core::hash::{Hash, Hasher};
use core::iter::FromIterator;
use core::mem;
use core::ops;
use collections::slice;
use core::str;
use collections::String;
use sys::AsInner;
use collections::Vec;
use std::fmt;
use std::hash::{Hash, Hasher};
use std::iter::FromIterator;
use std::mem;
use std::ops;
use std::slice;
use std::str;
use super::AsInner;
const UTF8_REPLACEMENT_CHARACTER: &'static [u8] = b"\xEF\xBF\xBD";
Loading…
Cancel
Save