Jakub Kotur | 835fea4 | 2020-12-21 17:28:14 +0100 | [diff] [blame] | 1 | //! Generic constructors for newtypes |
| 2 | |
| 3 | #![allow(non_snake_case)] |
| 4 | |
| 5 | use crate::{Font as FontType, Label as LabelType, Output as OutputType, Title as TitleType}; |
| 6 | use std::borrow::Cow; |
| 7 | use std::path::Path; |
| 8 | |
| 9 | /// Generic constructor for `Font` |
| 10 | #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] |
| 11 | #[inline(always)] |
| 12 | pub fn Font<S>(string: S) -> FontType |
| 13 | where |
| 14 | S: Into<Cow<'static, str>>, |
| 15 | { |
| 16 | FontType(string.into()) |
| 17 | } |
| 18 | |
| 19 | /// Generic constructor for `Label` |
| 20 | #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] |
| 21 | #[inline(always)] |
| 22 | pub fn Label<S>(string: S) -> LabelType |
| 23 | where |
| 24 | S: Into<Cow<'static, str>>, |
| 25 | { |
| 26 | LabelType(string.into()) |
| 27 | } |
| 28 | |
| 29 | /// Generic constructor for `Title` |
| 30 | #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] |
| 31 | #[inline(always)] |
| 32 | pub fn Title<S>(string: S) -> TitleType |
| 33 | where |
| 34 | S: Into<Cow<'static, str>>, |
| 35 | { |
| 36 | TitleType(string.into()) |
| 37 | } |
| 38 | |
| 39 | /// Generic constructor for `Output` |
| 40 | #[cfg_attr(feature = "cargo-clippy", allow(clippy::inline_always))] |
| 41 | #[inline(always)] |
| 42 | pub fn Output<P>(path: P) -> OutputType |
| 43 | where |
| 44 | P: Into<Cow<'static, Path>>, |
| 45 | { |
| 46 | OutputType(path.into()) |
| 47 | } |