Home / Docs / Standard library / Prelude

trim_start

Release v0.4.0Edition 0.2 and later

A function of the prelude, in scope in every module. Edition 0.2 and later.

una
pub trim_start(t: Text) -> Text
  ensures result.len <= t.len

t without Unicode white space at its start (spec/22 §2).

Parameters

Returns

Text: t without the Unicode White_Space at its start; never longer than t.

See also

trim, trim_end

Cost

Time O(result + trimmed) (ADR 0070), where:

Example

src/shop.unauna
module shop

--- An article number typed with spaces before it.
pub main() -> Unit
  uses @console: Console[print]
=
  let number = "  0042  ".trim_start()
  @console.print("[{number}]")

una run . prints:

Output
[0042  ]

Specification

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.