Expand description
§use-catalan
Small Catalan-family counting helpers for `RustUse`.
Checked Catalan and Fuss-Catalan numbers for exact sequence-counting workflows.
§Install
[dependencies]
use-catalan = "0.0.1"§Foundation
use-catalan provides a deliberately small exact-counting surface for Catalan-family sequences. The crate currently exposes catalan(n) for standard Catalan numbers and fuss_catalan(order, n) for the generalized Fuss-Catalan family. Results stay in checked u128 arithmetic, and overflow or invalid order values surface as explicit CatalanError values.
Standard Catalan numberscatalan(n) covers balanced-parenthesization and binary-tree style counts with exact u128 results.
|
Generalized Fuss-Catalanfuss_catalan(order, n) extends the same counting surface to the wider Catalan family.
|
Explicit failure modesCatalanError reports zero-order inputs and overflow instead of silently truncating counts.
|
| Helper group | Primary items | Best fit |
|---|---|---|
| Standard Catalan | catalan, CatalanError | Exact counts for binary-tree, Dyck-word, and balanced-parenthesization style problems |
| Generalized Catalan | fuss_catalan | Wider Catalan-family counts without a broader sequence toolbox |
§When to use directly
Choose use-catalan directly when Catalan-family sequence helpers are the only surface you need and you want to keep that concern explicit and narrow.
| Scenario | Use use-catalan directly? | Why |
|---|---|---|
| You only need exact Catalan counts | Yes | The crate stays smaller than the facade and keeps the counting domain explicit |
| You need generalized Fuss-Catalan counts alongside standard Catalan numbers | Yes | The current surface already covers both without a broader sequence abstraction |
| You also need combinatorics, geometry, or other math domains | Usually no | use-math can unify the concrete surfaces behind feature flags |
§Scope
- The current surface is intentionally small and concrete.
- Sequence values use checked
u128arithmetic and return explicit errors at the boundary. - General combinatorics helpers and broader sequence APIs belong in adjacent focused crates.
§Examples
§Standard Catalan numbers
use use_catalan::catalan;
assert_eq!(catalan(4)?, 14);
assert_eq!(catalan(10)?, 16_796);
§Generalized Fuss-Catalan numbers
use use_catalan::fuss_catalan;
assert_eq!(fuss_catalan(2, 4)?, 14);
assert_eq!(fuss_catalan(3, 3)?, 12);
§Status
use-catalan is a concrete pre-1.0 crate in the RustUse docs surface. The API remains intentionally small while adjacent sequence and combinatorics crates continue to grow around it.
Catalan-family utilities for RustUse.
Re-exports§
pub use counting::catalan;pub use counting::fuss_catalan;pub use error::CatalanError;