---
title: "trim_end"
url: https://una-lang.org/en/docs/std/prelude/trim_end/
release: v0.4.0
edition: "0.2 and later"
source: https://github.com/una-lang/una/blob/v0.4.0/docs/std/listing.json
---

# trim_end

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

- `t`: the text

## Returns

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

## See also

[`trim`](https://una-lang.org/en/docs/std/prelude/trim/), [`trim_start`](https://una-lang.org/en/docs/std/prelude/trim_start/)

## Cost

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

- `result`: the length of the result in UTF\-8 bytes
- `trimmed`: the length in UTF\-8 bytes of the white space removed

## Example

`src/shop.una`

```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:

```text
[  Lamp]
```

## Specification

- [`spec/22 §2`](https://una-lang.org/en/docs/spec/22-text/#s2)

Generated from the standard modules of una v0.4.0 ([`docs/std/listing.json`](https://github.com/una-lang/una/blob/5fec93d88932b333feec25e589355a2cb34c37b5/docs/std/listing.json), which is not part of the specification). The specification governs: [`spec/14 §1`](https://una-lang.org/en/docs/spec/14-standard-library/#s1).
