Home / Docs / Standard library / Prelude
trim
Release v0.4.0Edition 0.1 and later
A function of the prelude, in scope in every module. Edition 0.1 and later.
una
pub trim(t: Text) -> Text
ensures result.len <= t.lent without the Unicode whitespace at both ends (spec/14 §1).
Parameters
t: the text
Returns
Text: t without the Unicode White_Space at both ends; never longer than t.
Use instead
trim_start(edition 0.2 on) to keep the UnicodeWhite_Spaceat the endtrim_end(edition 0.2 on) to keep the UnicodeWhite_Spaceat the start
Example
src/shop.una
module shop
--- A product name typed with spaces around it.
pub main() -> Unit
uses @console: Console[print]
=
let name = " Desk lamp ".trim()
@console.print("[{name}]")una run . prints:
Output
[Desk 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.