• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

src/H03-May-2022-545334

.cargo-checksum.jsonH A D03-May-202289 11

.gitignoreH A D14-Jul-201830 43

Cargo.tomlH A D01-Jan-1970864 2421

Cargo.toml.orig-cargoH A D17-Jul-2018340 1210

README.mdH A D17-Jul-20181 KiB5037

README.md

1# thin-slice
2
3An owned slice that packs the slice storage into a single word when possible.
4
5## Usage
6
7```rust
8extern crate thin_slice;
9
10use std::mem;
11use thin_slice::ThinBoxedSlice;
12
13struct Ticket {
14    numbers: Box<[u8]>,
15    winning: bool,
16}
17
18struct ThinTicket {
19    numbers: ThinBoxedSlice<u8>,
20    winning: bool,
21}
22
23fn main() {
24    let nums = vec![4, 8, 15, 16, 23, 42].into_boxed_slice();
25    let ticket = ThinTicket {
26        numbers: nums.into(),
27        winning: false,
28    };
29    println!("Numbers: {:?}", ticket.numbers);
30
31    println!("size_of::<usize>():      {}", mem::size_of::<usize>());
32    println!("size_of::<Ticket>():     {}", mem::size_of::<Ticket>());
33    println!("size_of::<ThinTicket>(): {}", mem::size_of::<ThinTicket>());
34}
35```
36
37Output on `x86_64`:
38
39```
40Numbers: [4, 8, 15, 16, 23, 42]
41size_of::<usize>():      8
42size_of::<Ticket>():     24
43size_of::<ThinTicket>(): 16
44```
45
46## License
47
48thin-slice is distributed under the terms of the
49[Mozilla Public License, v. 2.0](https://www.mozilla.org/MPL/2.0/).
50