Home / Docs / Standard library / Prelude
contains_text
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 contains_text(t: Text, part: Text) -> BoolWhether part occurs in t (spec/22 §2).
Parameters
t: the textpart: the text to look for
Returns
Bool: true when part occurs in t.
Use instead
findto know where it occurs
See also
Cost
Time O(b + m) (ADR 0070), where:
b: the length oftin UTF-8 bytesm: the length ofpartin UTF-8 bytes
Example
src/shop.una
module shop
--- Whether a product description names a finish.
pub main() -> Unit
uses @console: Console[print]
=
let brass = "Desk lamp, brass".contains_text(part: "brass")
@console.print("brass: {brass}")
let steel = "Desk lamp, brass".contains_text(part: "steel")
@console.print("steel: {steel}")una run . prints:
Output
brass: true
steel: falseSpecification
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.