Home / Docs / Standard library / Prelude

trim_end

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_end(t: Text) -> Text
  ensures result.len <= t.len

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

Parameters

Returns

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

See also

trim, trim_start

Cost

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

Example

src/shop.unauna
module shop

--- A product name with spaces after it.
pub main() -> Unit
  uses @console: Console[print]
=
  let name = "  Lamp   ".trim_end()
  @console.print("[{name}]")

una run . prints:

Output
[  Lamp]

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.