standard_lib/lib.rs
1//! This crate is my attempt at writing (some key parts of) a standard library.
2//!
3//! Also: I wrote a theme (and extensions) for rustdoc, check it out under "Settings".
4//!
5//! # Purpose
6//! This repo / crate is a project that I'm working on as a learning experience, with no expectation
7//! for it to be used in production. Writing these data structures helps me to understand and
8//! appreciate them properly as well as scratching my "I could write that" itch.
9//!
10//! # Method
11//! All data structures here are written based on my existing understanding and problem solving. I'm
12//! not following any guides or copying from the standard library but neither am I restricting my
13//! self from looking things up or referring to existing crates, especially their APIs. This project
14//! isn't intended to copy Rust's [`std`] but rather takes a lot of inspiration from it.
15//!
16//! Although, I'm not writing this for production use, I intend to write it to a level where it
17//! could be. I've been relatively cautious about unsafe code and panics, although there are almost
18//! certainly some mistakes.
19//!
20//! # Error Handling
21//! I'm still pretty new to Rust, so I'm still trying to pin down when and how to use [`Result`]s
22//! effectively. Specifically for a standard library, it is more ergonomic for functions to panic in
23//! some cases, because users don't want to be forced to handle an error every time they invoke a
24//! method. For example, imagine having to handle the possibility of a capacity overflow every time
25//! you push into a Vector. (The maximum capacity of a Vector on a 64-bit system is `9,223,372`
26//! terabytes - more than Linux's maximum RAM capabilities. *I swear I didn't find that out the hard
27//! way by writing a unit test for maximum capacity.*)
28//!
29//! When this crate employs errors via [`Result`]s, it does so in a method that is strongly typed,
30//! using enums for static dispatch rather than dynamic, with structs (often ZSTs) that implement
31//! [`Error`](std::error::Error) (Which apparently isn't a given).
32//!
33//! # Dependencies
34//! At the moment, this crate uses `std`, which doesn't make sense for a real standard library. If I
35//! write an allocator in the future, I might able to make this `#![no_std]` but until then, I'm
36//! stuck with it. I'm not going to go an use [`Vec`] to write
37//! [`Vector`](collections::contiguous::Vector) or anything. In fact, this library doesn't use
38//! [`Vec`] at all.
39//!
40//! The [`fs`] module of this crate relies on `libc` for its thin syscall wrappers, providing strong
41//! typing and portability.
42//!
43//! This crate also depends on some derive macros because they're helpful and remove the need for
44//! some very repetitive programming.
45//!
46//! # Potential Future Additions
47//! - Linux syscall-based components:
48//! - Allocation
49//! - Threads / Processes
50//! - Time
51//! - Basic Networking
52//! - Data structures:
53//! - Binary Tree Map/Set
54//! - BTree Map/Set
55#![feature(strict_overflow_ops)]
56#![feature(box_vec_non_null)]
57#![feature(extend_one)]
58#![feature(extend_one_unchecked)]
59#![feature(trusted_len)]
60#![feature(debug_closure_helpers)]
61#![feature(raw_os_error_ty)]
62#![feature(ptr_as_ref_unchecked)]
63#![feature(doc_cfg)]
64#![feature(slice_from_ptr_range)]
65
66// #![warn(missing_docs)]
67#![warn(clippy::missing_safety_doc)]
68#![warn(clippy::undocumented_unsafe_blocks)]
69#![warn(clippy::missing_const_for_fn)]
70#![warn(clippy::missing_panics_doc)]
71#![warn(clippy::unwrap_used)]
72#![allow(clippy::module_inception)]
73
74pub mod collections;
75pub mod fs;
76
77pub(crate) mod util;