Skip to main content

kas_text/format/
plain.rs

1// Licensed under the Apache License, Version 2.0 (the "License");
2// you may not use this file except in compliance with the License.
3// You may obtain a copy of the License in the LICENSE-APACHE file or at:
4//     https://www.apache.org/licenses/LICENSE-2.0
5
6//! Implementations for plain text
7
8use super::{FontToken, FormattableText};
9use crate::Effect;
10
11impl FormattableText for str {
12    type FontTokenIter<'a>
13        = std::iter::Empty<FontToken>
14    where
15        Self: 'a;
16
17    fn as_str(&self) -> &str {
18        self
19    }
20
21    fn font_tokens<'a>(&'a self, _: f32) -> Self::FontTokenIter<'a> {
22        std::iter::empty()
23    }
24
25    fn effect_tokens(&self) -> &[Effect] {
26        &[]
27    }
28}
29
30impl FormattableText for String {
31    type FontTokenIter<'a> = std::iter::Empty<FontToken>;
32
33    fn as_str(&self) -> &str {
34        self
35    }
36
37    fn font_tokens<'a>(&'a self, _: f32) -> Self::FontTokenIter<'a> {
38        std::iter::empty()
39    }
40
41    fn effect_tokens(&self) -> &[Effect] {
42        &[]
43    }
44}