tap

Suffix-position tap and pipe extension methods for every Rust type

Library
Cargo
v1.0.1
507stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
31/100Needs Attention
Development Activity0
Maintenance0
Community36
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
79/100Good
Architecture78
Code Quality80
Innovation72
Learning Curve88

tap provides suffix-position pipeline behavior for Rust by adding extension methods to every type. Its Tap traits let you inspect or mutate a value in the middle of a method chain without rebinding, while its Pipe traits let you feed any value into a function using method-call syntax.

By turning free functions and debugging side-effects into chainable, suffix-position calls, tap keeps expressions linear and readable. It also offers Conv and TryConv traits for ergonomic type conversions, all with zero runtime cost.

What You Get

  • Tap and TapMut traits for inspecting or mutating a value mid-chain without rebinding
  • Pipe traits that let any value flow into a function via method-call syntax
  • Conv and TryConv traits for ergonomic infallible and fallible type conversions
  • Variants like tap_ok, tap_some, and tap_err for tapping into Result and Option internals

Common Use Cases

  • Inserting logging or assertions into a method chain without breaking it apart
  • Applying a mutation to a freshly constructed value in a single expression
  • Piping a value through a free function using fluent suffix syntax

Under The Hood

Architecture - The crate is tiny and trait-driven: src/tap.rs defines the Tap/TapMut traits and their Result/Option-aware variants (tap_ok, tap_some, tap_err), src/pipe.rs defines the Pipe traits, and src/conv.rs defines Conv/TryConv. lib.rs re-exports everything via a prelude. Each trait carries a blanket impl over all Sized types, so the methods appear on every value.

Tech Stack - Pure Rust with no external dependencies (100% Rust, ~30KB). It compiles on stable and is no_std-compatible, relying only on core traits like Into and TryInto for the conversion helpers.

Code Quality - The code is small, heavily documented with doctests, and stable at 1.0. Because every method is a thin, inline-friendly wrapper around a closure or conversion, there is little surface area for bugs; the project is mature and effectively feature-complete rather than actively developed.

API Design - The design is the selling point: extension methods that read in suffix position let debugging and transformation slot into existing chains without restructuring. Naming is consistent (tap/tap_mut/pipe/conv) and a prelude import brings the whole API into scope, giving an extremely shallow learning curve.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search