try_index 0.1.0

A boilerplate library that provides traits TryIndex and TryIndexMut.
Documentation
  • Coverage
  • 42.86%
    3 out of 7 items documented1 out of 5 items with examples
  • Size
  • Source code size: 24.99 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.73 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 14s Average build duration of successful builds.
  • all releases: 14s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • aerkiaga/try_index
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • aerkiaga

try_index

A boilerplate library that provides traits TryIndex and TryIndexMut.

Unlike the ones in try_traits, this gives explicit implementations for all standard library collections, which can actually fail. In exchange, no blanket implementation is provided.

use try_index::*;

let foo = vec![4, 3, 6, 2];
assert_eq!(foo.try_index(2), Some(&6));
assert_eq!(foo.try_index(4), None);
assert_eq!(foo.try_index(1..=2), Some(&[3, 6][..]));

This crate has a default std feature that may be disabled for no_std support, as well as an alloc feature that enables no_std alloc container types. See documentation for more information.

License

Copyright 2026 Developers of the try_index project

try_index is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See files LICENSE-APACHE and LICENSE-MIT, and COPYRIGHT for details.