Debian Codegraph @

debian/missing-sources/tinyvec/src/lib.rs

raw symbols SCIP
1 #![cfg_attr(not(feature = "std"), no_std)]
2 #![forbid(unsafe_code)]
3 #![cfg_attr(
4 feature = "nightly_slice_partition_dedup",
5 feature(slice_partition_dedup)
6 )]
7 #![cfg_attr(
8 feature = "debugger_visualizer",
9 feature(debugger_visualizer),
10 debugger_visualizer(natvis_file = "../debug_metadata/tinyvec.natvis")
11 )]
12 #![cfg_attr(docsrs, feature(doc_cfg))]
13 #![warn(clippy::missing_inline_in_public_items)]
14 #![warn(clippy::must_use_candidate)]
15 #![warn(missing_docs)]
16 #![allow(clippy::borrow_deref_ref)]
17 #![allow(unused_imports)]
18 #![allow(unused_mut)]
19 #![allow(clippy::write_with_newline)]
20 #![allow(clippy::needless_return)]
21
22 //! `tinyvec` provides 100% safe vec-like data structures.
23 //!
24 //! ## Provided Types
25 //! With no features enabled, this crate provides the [`ArrayVec`] type, which
26 //! is an array-backed storage. You can push values into the array and pop them
27 //! out of the array and so on. If the array is made to overflow it will panic.
28 //!
29 //! Similarly, there is also a [`SliceVec`] type available, which is a vec-like
30 //! that's backed by a slice you provide. You can add and remove elements, but
31 //! if you overflow the slice it will panic.
32 //!
33 //! With the `alloc` feature enabled, the crate also has a [`TinyVec`] type.
34 //! This is an enum type which is either an `Inline(ArrayVec)` or a `Heap(Vec)`.
35 //! If a `TinyVec` is `Inline` and would overflow it automatically transitions
36 //! itself into being `Heap` mode instead of a panic.
37 //!
38 //! All of this is done with no `unsafe` code within the crate. Technically the
39 //! `Vec` type from the standard library uses `unsafe` internally, but *this
40 //! crate* introduces no new `unsafe` code into your project.
41 //!
42 //! The limitation is that the element type of a vec from this crate must
43 //! support the [`Default`] trait. This means that this crate isn't suitable for
44 //! all situations, but a very surprising number of types do support `Default`.
45 //!
46 //! ## Other Features
47 //! * `grab_spare_slice` lets you get access to the "inactive" portions of an
48 //! ArrayVec.
49 //! * `serde` provides a `Serialize` and `Deserialize` implementation for
50 //! [`TinyVec`] and [`ArrayVec`] types, provided the inner item also has an
51 //! implementation.
52 //! * `borsh` provides a `BorshSerialize` and `BorshDeserialize` implementation
53 //! for [`TinyVec`] and [`ArrayVec`] types, provided the inner item also has
54 //! an implementation.
55 //!
56 //! ## API
57 //! The general goal of the crate is that, as much as possible, the vecs here
58 //! should be a "drop in" replacement for the standard library `Vec` type. We
59 //! strive to provide all of the `Vec` methods with the same names and
60 //! signatures. The exception is that the element type of some methods will have
61 //! a `Default` bound that's not part of the normal `Vec` type.
62 //!
63 //! The vecs here also have a few additional methods that aren't on the `Vec`
64 //! type. In this case, the names tend to be fairly long so that they are
65 //! unlikely to clash with any future methods added to `Vec`.
66
67 #[allow(unused_imports)]
68 use corerust-analyzer cargo core https://github.com/rust-lang/rust/library/core crate/::{
69 borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/::{Borrowrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/Borrow#, BorrowMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core borrow/BorrowMut#},
70 cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::PartialEqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialEq#,
71 convertrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/::AsMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsMut#,
72 defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/::Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#,
73 fmtrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/::{
74 Binaryrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Binary#, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Debug#, Displayrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Display#, Formatterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Formatter#, LowerExprust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerExp#, LowerHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/LowerHex#, Octalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Octal#, Pointerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/Pointer#,
75 UpperExprust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperExp#, UpperHexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/UpperHex#,
76 },
77 hashrust-analyzer cargo core https://github.com/rust-lang/rust/library/core 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#},
78 iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/::{Extendrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/Extend#, FromIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/FromIterator#, FusedIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/marker/FusedIterator#, IntoIteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/collect/IntoIterator#, Iteratorrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#},
79 memrust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/::{needs_droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/needs_drop()., replacerust-analyzer cargo core https://github.com/rust-lang/rust/library/core mem/replace().},
80 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#, Indexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#, IndexMutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#, RangeBoundsrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeBounds#},
81 slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/::SliceIndexrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/index/SliceIndex#,
82 };
83
84 #[cfg(feature = "alloc")]
85 #[doc(hidden)] // re-export for macros
86 pub extern crate allocrust-analyzer cargo tinyvec 1.10.0 alloc/;
87
88 mod arrayrust-analyzer cargo tinyvec 1.10.0 array/;
89 pub use arrayrust-analyzer cargo tinyvec 1.10.0 array/::*;
90
91 mod arrayvecrust-analyzer cargo tinyvec 1.10.0 arrayvec/;
92 pub use arrayvecrust-analyzer cargo tinyvec 1.10.0 arrayvec/::*;
93
94 mod arrayvec_drainrust-analyzer cargo tinyvec 1.10.0 arrayvec_drain/;
95 pub use arrayvec_drainrust-analyzer cargo tinyvec 1.10.0 arrayvec_drain/::*;
96
97 mod slicevecrust-analyzer cargo tinyvec 1.10.0 slicevec/;
98 pub use slicevecrust-analyzer cargo tinyvec 1.10.0 slicevec/::*;
99
100 #[cfg(feature = "alloc")]
101 mod tinyvecrust-analyzer cargo tinyvec 1.10.0 tinyvec/;
102 #[cfg(feature = "alloc")]
103 pub use craterust-analyzer cargo tinyvec 1.10.0 crate/::tinyvecrust-analyzer cargo tinyvec 1.10.0 tinyvec/::*;