Skip to main content

Crate use_catalan

Crate use_catalan 

Source
Expand description

§use-catalan

Small Catalan-family counting helpers for `RustUse`.
Checked Catalan and Fuss-Catalan numbers for exact sequence-counting workflows.

Rust 1.95.0+ Edition 2024 Catalan counting License MIT or Apache-2.0

§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 numbers
catalan(n) covers balanced-parenthesization and binary-tree style counts with exact u128 results.
Generalized Fuss-Catalan
fuss_catalan(order, n) extends the same counting surface to the wider Catalan family.
Explicit failure modes
CatalanError reports zero-order inputs and overflow instead of silently truncating counts.
Helper groupPrimary itemsBest fit
Standard Catalancatalan, CatalanErrorExact counts for binary-tree, Dyck-word, and balanced-parenthesization style problems
Generalized Catalanfuss_catalanWider 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.

ScenarioUse use-catalan directly?Why
You only need exact Catalan countsYesThe crate stays smaller than the facade and keeps the counting domain explicit
You need generalized Fuss-Catalan counts alongside standard Catalan numbersYesThe current surface already covers both without a broader sequence abstraction
You also need combinatorics, geometry, or other math domainsUsually nouse-math can unify the concrete surfaces behind feature flags

§Scope

  • The current surface is intentionally small and concrete.
  • Sequence values use checked u128 arithmetic 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;

Modules§

counting
error
prelude
Common ergonomic imports for use-catalan.