ov 0.0.1

a collection of traits that allow you to chain off of anything
Documentation
  • Coverage
  • 9.09%
    1 out of 11 items documented1 out of 11 items with examples
  • Ø build duration
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • brigand

ov

The 'ov' crate provides a collection of traits that allow you to chain off of anything. Each trait has a single method with the same name as the trait (but in snake case).

Over, OverRef, and OverMut are each of self, &self, and &mut self, and the callback receives that same value. They are implemented for all types.

OverDeref and OverDerefMut are implemented for types which have Deref and DerefMut implementations. They both borrow the receiver, and pass a reference of the Deref::target to the callback.

Examples

use ov::*;
let mut n = 5;
assert_eq!(n.over(|n| n * 2), 10);
n.over_mut(|n| {
  *n *= 3
});
assert_eq!(n, 15);

let s = String::from("Hello, world!");
// Note: this would fail if `s` is `String` or `&String`
let len = s.over_deref(|s| str::len(s));
assert_eq!(len, 13);