Rust modules in TypeScript

TypeScript implementations of 23 Rust standard library functions across 1 module. Each function is individually importable and tree-shakeable.

str

We have 23 Rust functions so far - help us add more

Got a rainy Sunday afternoon and a taste for a porting puzzle?

  • Get inspiration from the Rust std::str docs.
  • Click "New file" in the appropriate folder on GitHub. This will fork the project to your account, directly add the file to it, and send a Pull Request to us.

We will then review it. If it's useful to the project and in line with our contributing guidelines your work will become part of Locutus and you'll be automatically credited in the authors section accordingly.

Upstream Surface Inventory 23/216 shipped · 166 next 11%

Locutus tracks 12 upstream namespaces for Rust and sorts them into what is already shipped, what we still want, what we intentionally keep, and what still needs a decision.

This inventory now tracks a broader slice of Rust core/std primitives and slice helpers first, excluding the wider crate ecosystem.

11% catalog shipped
Shipped Next Explicit non-goals
str 68% f32 0% f64 0% char 0% i32 0% u32 0% usize 0% slice 0% cmp 0% bool 0% option 0% result 0%
Tracked namespaces 12
Shipped 23/216
Next to port 166
Explicit non-goals 27

str primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.str.html

88% shipped
23/26 shipped 3 next 8 explicit non-goals
str
Shipped (23)

Next

Remaining string helpers are useful plain-value portability targets unless they depend on iterators or byte semantics.

  • is_ascii
  • repeat
  • split_ascii_whitespace
Explicit non-goals (8)
  • bytes Skip Byte iterators do not fit Locutus' current plain-value model.
  • char_indices Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • chars Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • matches Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • parse Skip Generic trait-driven parsing does not map cleanly to JS plain values.
  • rmatch_indices Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • rmatches Skip Iterator-returning APIs do not fit Locutus' plain-value model.
  • trim_matches Skip Pattern-driven trimming does not map cleanly to one stable plain-value contract.

f32 primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.f32.html

0% shipped
0/46 shipped 46 next

Next

Scalar floating-point helpers are strong Rust portability targets.

  • abs
  • acos
  • acosh
  • asin
  • asinh
  • atan
  • atan2
  • atanh
  • cbrt
  • ceil
  • clamp
  • copysign
  • cos
  • cosh
  • exp
  • exp_m1
  • exp2
  • floor
  • fract
  • hypot
  • is_finite
  • is_infinite
  • is_nan
  • is_normal
  • ln
  • ln_1p
  • log
  • log10
  • log2
  • max
  • min
  • mul_add
  • powf
  • powi
  • recip
  • round
  • signum
  • sin
  • sinh
  • sqrt
  • tan
  • tanh
  • to_degrees
  • to_radians
  • total_cmp
  • trunc

f64 primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.f64.html

0% shipped
0/46 shipped 46 next

Next

Scalar floating-point helpers are strong Rust portability targets.

  • abs
  • acos
  • acosh
  • asin
  • asinh
  • atan
  • atan2
  • atanh
  • cbrt
  • ceil
  • clamp
  • copysign
  • cos
  • cosh
  • exp
  • exp_m1
  • exp2
  • floor
  • fract
  • hypot
  • is_finite
  • is_infinite
  • is_nan
  • is_normal
  • ln
  • ln_1p
  • log
  • log10
  • log2
  • max
  • min
  • mul_add
  • powf
  • powi
  • recip
  • round
  • signum
  • sin
  • sinh
  • sqrt
  • tan
  • tanh
  • to_degrees
  • to_radians
  • total_cmp
  • trunc

char primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.char.html

0% shipped
0/25 shipped 25 next 6 explicit non-goals

Next

Character classification and ASCII-case helpers are strong plain-value portability targets.

  • from_digit
  • is_alphabetic
  • is_alphanumeric
  • is_ascii
  • is_ascii_alphabetic
  • is_ascii_alphanumeric
  • is_ascii_control
  • is_ascii_digit
  • is_ascii_graphic
  • is_ascii_hexdigit
  • is_ascii_lowercase
  • is_ascii_punctuation
  • is_ascii_uppercase
  • is_ascii_whitespace
  • is_control
  • is_digit
  • is_lowercase
  • is_numeric
  • is_uppercase
  • is_whitespace
  • len_utf16
  • len_utf8
  • to_ascii_lowercase
  • to_ascii_uppercase
  • to_digit
Explicit non-goals (6)
  • encode_utf16 Skip Iterator-like encoding sinks do not fit Locutus' plain-value model.
  • escape_debug Skip Escape iterators do not fit Locutus' plain-value model.
  • escape_default Skip Escape iterators do not fit Locutus' plain-value model.
  • escape_unicode Skip Escape iterators do not fit Locutus' plain-value model.
  • to_lowercase Skip Multi-codepoint case iterators do not fit one stable plain-value contract.
  • to_uppercase Skip Multi-codepoint case iterators do not fit one stable plain-value contract.

i32 primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.i32.html

0% shipped
0/11 shipped 11 next

Next

Signed integer helpers are strong Rust portability targets.

  • abs
  • checked_abs
  • checked_add
  • checked_sub
  • clamp
  • is_negative
  • is_positive
  • max
  • min
  • pow
  • signum

u32 primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.u32.html

0% shipped
0/8 shipped 8 next

Next

Unsigned integer helpers are strong Rust portability targets.

  • checked_add
  • checked_sub
  • clamp
  • is_power_of_two
  • max
  • min
  • next_power_of_two
  • pow

usize primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.usize.html

0% shipped
0/8 shipped 8 next

Next

Pointer-sized integer helpers are strong Rust portability targets.

  • checked_add
  • checked_sub
  • clamp
  • is_power_of_two
  • max
  • min
  • next_power_of_two
  • pow

slice primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.slice.html

0% shipped
0/7 shipped 7 next 7 explicit non-goals

Next

Search helpers have a clean plain-value contract.

  • binary_search

Membership helpers have a clean plain-value contract.

  • contains

Boundary checks have a clean plain-value contract.

  • ends_with
  • starts_with

Boundary readers have a clean plain-value contract.

  • first
  • last

Size helpers have a clean plain-value contract.

  • len
Explicit non-goals (7)
  • binary_search_by Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • binary_search_by_key Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • get Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • is_empty Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • partition_point Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • strip_prefix Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.
  • strip_suffix Skip Many slice methods are iterator- or mutability-heavy rather than one stable plain-value contract.

std::cmp functions

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/cmp/index.html

0% shipped
0/6 shipped 6 next

Next

Comparison helpers over plain values are strong Rust portability targets.

  • max
  • max_by
  • max_by_key
  • min
  • min_by
  • min_by_key

bool primitive methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/primitive.bool.html

0% shipped
0/2 shipped 2 next

Next

Boolean combinator helpers have a clean plain-value contract.

  • then
  • then_some

Option methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/option/enum.Option.html

0% shipped
0/2 shipped 2 next 3 explicit non-goals

Next

Optional-value predicates have a clean plain-value contract.

  • is_none
  • is_some
Explicit non-goals (3)
  • map Skip Option combinators revolve around sum-type wrappers rather than one stable plain-value contract.
  • ok_or Skip Option combinators revolve around sum-type wrappers rather than one stable plain-value contract.
  • unwrap_or Skip Option combinators revolve around sum-type wrappers rather than one stable plain-value contract.

Result methods

Rust 1.85 · Catalog source: manual inventory https://doc.rust-lang.org/std/result/enum.Result.html

0% shipped
0/2 shipped 2 next 3 explicit non-goals

Next

Result predicates have a clean plain-value contract.

  • is_err
  • is_ok
Explicit non-goals (3)
  • map Skip Result combinators revolve around sum-type wrappers rather than one stable plain-value contract.
  • map_err Skip Result combinators revolve around sum-type wrappers rather than one stable plain-value contract.
  • unwrap_or Skip Result combinators revolve around sum-type wrappers rather than one stable plain-value contract.