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

..03-May-2022-

src/H03-May-2022-7,0524,342

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

.cargo_vcs_info.jsonH A D02-Dec-202074 65

.gitignoreH A D09-Oct-202030 43

Cargo.tomlH A D02-Dec-2020957 2926

Cargo.toml.orig-cargoH A D02-Dec-2020526 2117

LICENSE-APACHEH A D09-Oct-202010.6 KiB202169

LICENSE-MITH A D09-Oct-20201 KiB2622

README.mdH A D02-Dec-20202.2 KiB7451

README.md

1Fallible Collections.rs
2==============
3
4Implement api on rust collection wich returns a result when an allocation error occurs.
5This is inspired a lot by [RFC 2116](https://github.com/rust-lang/rfcs/blob/master/text/2116-alloc-me-maybe.md).
6
7The api currently propose a fallible interface for Vec, Box, Arc, Btree and Rc,
8a TryClone trait wich is implemented for primitive rust traits and a fallible format macro.
9
10You can use this with try_clone_derive crate wich derive TryClone for your own types.
11
12# Getting Started
13
14[fallible collections is available on crates.io](https://crates.io/crates/fallible_collections).
15It is recommended to look there for the newest released version, as well as links to the newest builds of the docs.
16
17At the point of the last update of this README, the latest published version could be used like this:
18
19Add the following dependency to your Cargo manifest...
20
21```toml
22[dependencies]
23fallible_collections = "0.3.1"
24```
25
26...and see the [docs](https://docs.rs/fallible_collections) for how to use it.
27
28# Example
29
30Exemple of using the FallibleBox interface.
31```rust
32use fallible_collections::FallibleBox;
33
34fn main() {
35	// this crate an Ordinary box but return an error on allocation failure
36	let mut a = Box::try_new(5).unwrap();
37	let mut b = Box::new(5);
38
39	assert_eq!(a, b);
40	*a = 3;
41	assert_eq!(*a, 3);
42}
43```
44
45Exemple of using the FallibleVec interface.
46```rust
47use fallible_collections::FallibleVec;
48
49fn main() {
50	// this crate an Ordinary Vec<Vec<u8>> but return an error on allocation failure
51	let a: Vec<Vec<u8>> = try_vec![try_vec![42; 10].unwrap(); 100].unwrap();
52	let b: Vec<Vec<u8>> = vec![vec![42; 10]; 100];
53	assert_eq!(a, b);
54	assert_eq!(a.try_clone().unwrap(), a);
55	...
56}
57```
58
59## License
60
61Licensed under either of
62
63 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
64 * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
65
66at your option.
67
68### Contribution
69
70Unless you explicitly state otherwise, any contribution intentionally submitted
71for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any
72additional terms or conditions.
73
74