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 @@
#![feature(alloc)] #![feature(alloc)]
#![feature(allow_internal_unstable)]
#![feature(collections)] #![feature(collections)]
#![feature(core_intrinsics)]
#![feature(char_escape_debug)] #![feature(char_escape_debug)]
#![feature(int_error_internals)] #![feature(int_error_internals)]
#![feature(lang_items)] #![feature(lang_items)]
#![feature(macro_reexport)]
#![feature(prelude_import)]
#![feature(slice_concat_ext)]
#![feature(slice_patterns)] #![feature(slice_patterns)]
#![feature(str_internals)] #![feature(str_internals)]
#![feature(try_from)] #![feature(try_from)]
@ -15,26 +20,60 @@
extern crate alloc; extern crate alloc;
extern crate alloc_system; extern crate alloc_system;
#[macro_use] extern crate collections; #[macro_reexport(format, vec)]
#[macro_use]
extern crate collections;
extern crate rustc_unicode; extern crate rustc_unicode;
extern crate ctru_sys as libctru; 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 console;
pub mod srv; pub mod srv;
pub mod gfx; pub mod gfx;
pub mod services; pub mod services;
pub mod sdmc; pub mod sdmc;
pub mod system;
pub mod ascii;
pub mod error;
pub mod ffi;
pub mod io;
pub mod memchr;
pub mod panic;
pub mod path;
mod sys;
pub use srv::Srv; pub use srv::Srv;
pub use gfx::Gfx; pub use gfx::Gfx;

4
src/services/fs.rs

@ -11,8 +11,8 @@ use core::mem;
use alloc::arc::Arc; use alloc::arc::Arc;
use collections::Vec; use collections::Vec;
use path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use ffi::OsString; use std::ffi::OsString;
use libctru::services::fs::*; 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 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use ascii; use std::ascii;
use collections::borrow::{Cow, Borrow, ToOwned}; use std::borrow::{Cow, Borrow};
use core::cmp::Ordering; use std::cmp::Ordering;
use error::Error; use std::error::Error;
use core::fmt::{self, Write}; use std::fmt::{self, Write};
use io; use std::io;
use libctru::libc::{self, c_char}; use libctru::libc::{self, c_char};
use core::mem; use std::mem;
use memchr; use system::memchr;
use core::ops; use std::ops;
use core::ptr; use std::ptr;
use core::slice; use std::slice;
use core::str::{self, Utf8Error}; use std::str::{self, Utf8Error};
use alloc::boxed::Box;
use collections::Vec;
use collections::String;
/// A type representing an owned C-compatible string /// 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 @@
// option. This file may not be copied, modified, or distributed // option. This file may not be copied, modified, or distributed
// except according to those terms. // except according to those terms.
use collections::borrow::{Borrow, Cow, ToOwned}; use std::borrow::{Borrow, Cow};
use core::fmt::{self, Debug}; use std::fmt::{self, Debug};
use core::mem; use std::mem;
use collections::String; use std::ops;
use core::ops; use std::cmp;
use core::cmp; use std::hash::{Hash, Hasher};
use core::hash::{Hash, Hasher};
use collections::Vec; use system::sys::wtf8::{Wtf8, Wtf8Buf};
use system::sys::{AsInner, IntoInner, FromInner};
use sys::wtf8::{Wtf8, Wtf8Buf}; pub use system::sys::wtf8::EncodeWide;
use sys::{AsInner, IntoInner, FromInner};
pub use sys::wtf8::EncodeWide;
/// A type that can represent owned, mutable platform-native strings, but is /// A type that can represent owned, mutable platform-native strings, but is
/// cheaply inter-convertible with Rust strings. /// cheaply inter-convertible with Rust strings.

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

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

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

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

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

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

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

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

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

@ -247,17 +247,13 @@
//! contract. The implementation of many of these functions are subject to change over //! contract. The implementation of many of these functions are subject to change over
//! time and may call fewer or more syscalls/library functions. //! time and may call fewer or more syscalls/library functions.
use std::cmp;
use core::cmp;
use rustc_unicode::str as core_str; use rustc_unicode::str as core_str;
use error as std_error; use std::error as std_error;
use core::fmt; use std::fmt;
use core::result; use std::result;
use core::str; use std::str;
use memchr; use std::memchr;
use collections::Vec;
use collections::String;
pub use self::buffered::{BufReader, BufWriter, LineWriter}; pub use self::buffered::{BufReader, BufWriter, LineWriter};
pub use self::buffered::IntoInnerError; 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 @@
#![allow(missing_copy_implementations)] #![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. /// 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 @@
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 @@
//! normalization is possible to build on top of the components APIs, //! normalization is possible to build on top of the components APIs,
//! and will be included in this library in the near future. //! and will be included in this library in the near future.
use ascii::*; use std::ascii::*;
use collections::borrow::{Borrow, ToOwned, Cow}; use std::borrow::{Borrow, ToOwned, Cow};
use core::cmp; use std::cmp;
//use error::Error; //use error::Error;
use core::fmt; use std::fmt;
//use fs; //use fs;
use core::hash::{Hash, Hasher}; use std::hash::{Hash, Hasher};
//use io; //use io;
use core::iter; use std::mem;
use core::mem; use std::ops::{self, Deref};
use core::ops::{self, Deref}; use std::iter;
use collections::String;
use collections::Vec;
use ffi::{OsStr, OsString}; use std::ffi::{OsStr, OsString};
use self::platform::{is_sep_byte, is_verbatim_sep, MAIN_SEP_STR, parse_prefix}; 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 { mod platform {
use super::Prefix; use super::Prefix;
use ffi::OsStr; use std::ffi::OsStr;
#[inline] #[inline]
pub fn is_sep_byte(b: u8) -> bool { pub fn is_sep_byte(b: u8) -> bool {

9
src/system/rt.rs

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