1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 //! # The Trusty Rust Standard Library
18 //!
19 //! Rust for Trusty requires `no_std`, as the Rust standard library has not been
20 //! (and will likely never be) ported to Trusty. This crate provides a subset of
21 //! the standard library types and other generally useful APIs for building
22 //! trusted apps.
23 //!
24 //! This library is designed to accommodate fallible memory allocation and
25 //! provides types which may only be allocated fallibly. When the necessary APIs
26 //! are available [upstream](https://github.com/rust-lang/rust/issues/86942) or
27 //! in this crate, we plan to enable `no_global_oom_handling`, so do not write
28 //! code using this crate that relies on infallible allocation.
29 
30 #![no_std]
31 #![allow(internal_features)]
32 #![feature(allocator_api)]
33 #![feature(alloc_error_handler)]
34 #![feature(alloc_layout_extra)]
35 #![feature(core_intrinsics)]
36 // min_specialization is only used to optimize CString::try_new(), so we can
37 // remove it if needed
38 #![feature(min_specialization)]
39 #![feature(new_uninit)]
40 #![feature(panic_info_message)]
41 #![feature(slice_internals)]
42 #![feature(slice_ptr_get)]
43 
44 // Import alloc with a different name to not clash with our local module
45 extern crate alloc as alloc_crate;
46 
47 pub mod alloc;
48 mod clone_ext;
49 pub mod ffi;
50 
51 pub use clone_ext::TryClone;
52 
53 // Re-exports from core and alloc
54 pub use alloc_crate::{borrow, boxed, fmt, format, rc, slice, str, string, vec};
55 
56 pub use core::{
57     any, arch, array, cell, char, clone, cmp, convert, default, future, hash, hint, i128, i16, i32,
58     i64, i8, intrinsics, isize, iter, marker, mem, ops, option, pin, primitive, ptr, result, u128,
59     u16, u32, u64, u8, usize,
60 };
61 
62 pub use core::{
63     assert_eq, assert_ne, debug_assert, debug_assert_eq, debug_assert_ne, matches, todo,
64     unimplemented, unreachable, write, writeln,
65 };
66 
67 pub use core::{
68     assert, cfg, column, compile_error, concat, env, file, format_args, include, include_bytes,
69     include_str, line, module_path, option_env, stringify,
70 };
71