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.lent without Unicode white space at its end (spec/22 §2).
Parameters
t: the text
Returns
Text: t without the Unicode White_Space at its end; never longer than t.
See also
Cost
Time O(result + trimmed) (ADR 0070), where:
result: the length of the result in UTF-8 bytestrimmed: the length in UTF-8 bytes of the white space removed
Example
src/shop.una
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.