Debian Codegraph @

src/lib.rs

raw symbols SCIP
1 //! `use std_prelude::*` so you can be ready to code!
2 //!
3 //! # Traits
4 //! Not having common traits imported is one of the most annoying gotchas in rust when coming from
5 //! other languages. When you are used to the language, you expect the commonly used methods to
6 //! always work... not so in rust! Using `Vec::from_iter` is extremely common, but you must first
7 //! import the `FromIterator` trait.
8 //!
9 //! The following are the traits that are exported and why:
10 //!
11 //! - **std::ascii::[AsciiExt](trait.AsciiExt.html)**: adds the `to_ascii_uppercase` onto `&str`
12 //! types.
13 //! - **std::borrow::[Borrow](trait.Borrow.html)**: for manually defining the `Borrow` trait.
14 //! - **std::cmp::{[Ord](enum.Ord.html), [PartialOrd](enum.PartialOrd.html)}**: for manually
15 //! defining the Ordering traits and using them in trait bounds.
16 //! - **std::fmt::[Debug](trait.Debug.html)**: allows you to define Debug manually and use in trait
17 //! bounds.
18 //! - **std::hash::{[Hash](trait.Hash.html), [Hasher](trait.Hasher.html)}**: allows you to
19 //! define Hash manually and use in trait bounds.
20 //! - **std::fmt::[Write as FmtWrite](trait.FmtWrite.html)**: adds `write_str` onto byte buffers
21 //! (such as `String`). Renamed `FmtWrite` to avoid conflict with `std::io::Write`
22 //! - **std::io::[BufRead](trait.BufRead.html)**: the `BufRead` trait allows you to use the methods
23 //! associated with the `BufReader` struct (also imported).
24 //! - **std::io::[Read](trait.Read.html)**: allows you to use `file.read()`
25 //! - **std::io::[Seek](trait.Seek.html)**: allows you to use `file.seek()`
26 //! - **std::io::[Write as IoWrite](trait.IoWrite.html)**: allows you to use `file.write()` and
27 //! `file.write_all()`. Renamed `IoWrite` to avoid conflict with `std::fmt::Write`
28 //! - **std::ops::{[Deref](trait.Deref.html), [DerefMut](trait.DerefMut.html)}**: allows deref
29 //! through `*v` and also enables Deref coercions
30 //! - **std::str::[FromStr](trait.FromStr.html)**: allows you to use `type::from_str` constructor
31 //! for several types. This is what is implicitly called with `str::parse<_>()`
32 //!
33 //! # Structs
34 //! These are extremely commonly used types and it is annoying to have to reimport them all the
35 //! time.
36 //!
37 //! - **std::borrow::[Cow](struct.Cow.html)**: A clone-on-write smart pointer (often called copy on
38 //! write in other languages). This is used by many libraries to be as efficient as possible when
39 //! returned data is identical to the data passed in, among other uses.
40 //! - **std::collections::{[BTreeMap](struct.BTreeMap.html), [HashMap](struct.HashMap.html),
41 //! [HashSet](struct.HashSet.html)}**: ordered-dict, dict and set
42 //! - **std::cmp::[Ordering](enum.Ordering.html)**: the enum type used in the Ordering traits.
43 //! - **std::ffi::[OsString](struct.OsString.html)**: os agnostic (non unicode) string type.
44 //! `std::path::PathBuf` uses this.
45 //! - **std::fs::[File](struct.File.html)**: for opening files.
46 //! - `File::open` to open a file for reading
47 //! - `File::write` to open a file for writing
48 //! - **std::fs::[OpenOptions](struct.OpenOptions.html)**: file opening options.
49 //! - **std::fs::[ReadDir](struct.ReadDir.html)**: to iterate over the entries in a directory.
50 //! - **std::io::[BufReader](struct.BufReader.html)**: the BufRead struct wraps `io::Read` using a
51 //! buffer reducing the number of OS calls and giving helpful methods
52 //! - `read_line()`: read a single line
53 //! - `lines()`: return an iterator over all lines.
54 //! - `split(byte: u8)`: return an iterator which splits at the chosen byte.
55 //! - **std::io::[BufWriter](struct.BufWriter.html)**: similar to `BufReader`, buffers writes to
56 //! reduce the number of calls to the OS. Provides no new methods.
57 //!
58 //! - **std::path::{[Path](struct.Path.html), [PathBuf](struct.PathBuf.html)}**: specifies an os
59 //! path.
60 //! - **std::rc::[Rc](struct.Rc.html)**: reference counted pointer
61 //! - **std::sync::[Arc](struct.Arc.html)**: atomically reference counted pointer
62 //! - **std::sync::[Mutex](struct.Mutex.html)**: mutual exclusion primitive for threading.
63 //! - **std::sync::atomic::{AtomicBool, AtomicIsize, AtomicUsize}**: basic atomic types. Good for
64 //! unique ids and lots of other use cases.
65 //! - **std::sync::atomic::[Ordering as AtomicOrdering](struct.AtomicOrdering.html)**: necessary
66 //! for performing operations on atomic types. For incrementing a counter use `val.fetch_add(1,
67 //! AtomicOrdering::SeqCst)`. Renamed to not conflict with `std::cmp::Ordering`.
68 //! - **std::sync::atomic::ATOMIC_USIZE_INIT**: initialized `AtomicUsize` of 0. Use with `static
69 //! COUNTER: AtomicUsize = ATOMIC_USIZE_INIT;`
70 //! - **std::time::[Duration](struct.Duration.html)**: an amount of time, used for
71 //! `std::thread::sleep`.
72 //!
73 //! # Functions
74 //! These are mostly just "nice to have" functions and it is *really* unlikely that they would ever
75 //! be overriden.
76 //!
77 //! - **std::cmp::{[max](fn.max.html), [min](fn.min.html)}**: get the max or min of two comparable integers.
78 //! - **std::mem::{[size_of](fn.size_of.html), [size_of_val](fn.size_of_val.html)}**: get the size
79 //! of a type. This is safe and common enough that it should be always available.
80 //! - **std::thread::[sleep](fn.sleep.html)**: put the thread to sleep for a `Duration`.
81 //! - **std::thread::[spawn](fn.spawn.html)**: spawn a function in a new thread. In rust this is
82 //! memory safe, so it is nice to have it always available.
83 //!
84 //! # Modules (_primitive type_ only)
85 //! The following modules are imported so that it is easy to access their relevant constants and
86 //! constructors.
87 //!
88 //! - **u8 u16 u64 usize**: unsigned integer modules with `MAX` and `MIN`
89 //! - **i8 i16 i64 isize**: signed integer modules with `MAX` and `MIN`
90 //! - **f32 f64**: floating point modules with not just `MAX` and `MIN` but also `NAN`, `INFINITY`,
91 //! etc as well as a [f32::consts](f32/consts/index.html) and [f64::consts](f64/consts/index.html)
92 //! modules with basic mathematical constants like `PI` and `E`.
93 //! - [**str**](str/index.html): core string type with [`from_utf8`](str/fn.from_utf8.html)
94 //! function.
95
96 // ------------------------------
97 // ----------- TRAITS -----------
98 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::asciirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ascii/::AsciiExtrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ascii/AsciiExt#;
99 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#;
100 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::{
101 Ordrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#, PartialOrdrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#, Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#
102 };
103 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fmtrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc fmt/::{Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Writerust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write# as FmtWriterust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Write#};
104 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::hashrust-analyzer cargo std https://github.com/rust-lang/rust/library/std hash/::{Hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hash#, Hasherrust-analyzer cargo core https://github.com/rust-lang/rust/library/core hash/Hasher#};
105 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{
106 BufReadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/BufRead#,
107 Readrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Read#, Seekrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Seek#, SeekFromrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/SeekFrom#,
108 Writerust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write# as IoWriterust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/Write#,
109 };
110 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#;
111 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::opsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/::{Derefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/Deref#, DerefMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/DerefMut#};
112 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/::FromStrrust-analyzer cargo core https://github.com/rust-lang/rust/library/core str/traits/FromStr#;
113
114
115 // -------------------------------
116 // ----------- STRUCTS -----------
117 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::borrowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/::Cowrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/Cow#;
118 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::collectionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/::{BTreeMaprust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc collections/btree/map/BTreeMap#, HashMaprust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/HashMap#, HashSetrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/HashSet#};
119 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::ffirust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/::OsStringrust-analyzer cargo std https://github.com/rust-lang/rust/library/std ffi/os_str/OsString#;
120 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::fsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/::{
121 Filerust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/File#,
122 OpenOptionsrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/OpenOptions#,
123 ReadDirrust-analyzer cargo std https://github.com/rust-lang/rust/library/std fs/ReadDir#,
124 };
125 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::{
126 BufReaderrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufreader/BufReader#, BufWriterrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/buffered/bufwriter/BufWriter#,
127 };
128 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::{Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#, PathBufrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/PathBuf#};
129 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/::Rcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc rc/Rc#;
130 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::{Arcrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc sync/Arc#, Mutexrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/poison/mutex/Mutex#};
131 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::syncrust-analyzer cargo std https://github.com/rust-lang/rust/library/std sync/::atomicrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/::{
132 AtomicBoolrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicBool#,
133 AtomicIsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicIsize#,
134 AtomicUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/AtomicUsize#,
135 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering# as AtomicOrderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/Ordering#,
136 ATOMIC_USIZE_INITrust-analyzer cargo core https://github.com/rust-lang/rust/library/core sync/atomic/ATOMIC_USIZE_INIT.,
137 };
138 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#;
139
140
141 // ---------------------------------
142 // ----------- FUNCTIONS -----------
143 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::{size_ofrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of()., size_of_valrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/size_of_val().};
144 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::threadrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/::{sleeprust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/sleep()., spawnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std thread/functions/spawn().};
145
146
147 // ---------------------------------
148 // ----------- MODULES -----------
149
150 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::u8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/u8/;
151 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::u16rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/u16/;
152 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::u64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/u64/;
153 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::usizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/usize/;
154 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::i8rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/i8/;
155 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::i16rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/i16/;
156 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::i64rust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/i64/;
157 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::isizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core legacy_int_modules/isize/;
158 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f32rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f32/;
159 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::f64rust-analyzer cargo std https://github.com/rust-lang/rust/library/std f64/;
160 pub use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::strrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc str/;