| commit | cf9e29e0f686faeb22fc2e1201339ab53b29305c | [log] [tgz] |
|---|---|---|
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | Mon Mar 23 20:46:13 2020 +0000 |
| committer | GitHub <noreply@github.com> | Mon Mar 23 20:46:13 2020 +0000 |
| tree | 96ff168e4e907053f5f1988289c7202570635bb9 | |
| parent | 246660c52874f20a2a633867c9b786f91b8a1004 [diff] | |
| parent | 8a6f5e3cc97f3762ac9841ce870edcee82df1dba [diff] |
Merge #23 23: Add a deref-removing impl for TextSized r=CAD97 a=CAD97 Notably, given `s: &SmolStr`, `TextSize::of(s)` does not work, where `TextUnit::of_str(s)` did, because the concrete type could be deref-coerced to. (It's probably a limitation of the language that deref coersion does not apply here, but it's one we have to live with.) So we provide a blanket impl for any type that derefs (directly) to `str`. Alternatively, we can provide a deeper blanket impl that derefs any number of references recursively [[playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=008b5e0c2edd332b34b3efa42ce2a40a)]: ```rust impl<D> TextSized for &'_ D where D: Deref, for<'a> &'a D::Target: TextSized, { #[inline] fn text_size(self) -> TextSize { self.deref().text_size() } } ``` This is "only" at the cost of a little extra impl complexity. Co-authored-by: CAD97 <cad97@cad97.com>
A library that provides newtype wrappers for u32 and (u32, u32) for use as text offsets.
See the docs for more.
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.