|
1 | | -#[derive(Debug, Clone, Copy)] |
| 1 | +#[derive(Debug, PartialEq, Eq, Copy, Clone)] |
2 | 2 | pub enum Quote { |
3 | 3 | Single, |
4 | 4 | Double, |
@@ -80,15 +80,21 @@ pub struct UnicodeEscape<'a> { |
80 | 80 | } |
81 | 81 |
|
82 | 82 | impl<'a> UnicodeEscape<'a> { |
| 83 | + #[inline] |
83 | 84 | pub fn with_forced_quote(source: &'a str, quote: Quote) -> Self { |
84 | 85 | let layout = EscapeLayout { quote, len: None }; |
85 | 86 | Self { source, layout } |
86 | 87 | } |
87 | | - pub fn new_repr(source: &'a str) -> Self { |
88 | | - let layout = Self::repr_layout(source, Quote::Single); |
| 88 | + #[inline] |
| 89 | + pub fn with_preferred_quote(source: &'a str, quote: Quote) -> Self { |
| 90 | + let layout = Self::repr_layout(source, quote); |
89 | 91 | Self { source, layout } |
90 | 92 | } |
91 | | - |
| 93 | + #[inline] |
| 94 | + pub fn new_repr(source: &'a str) -> Self { |
| 95 | + Self::with_preferred_quote(source, Quote::Single) |
| 96 | + } |
| 97 | + #[inline] |
92 | 98 | pub fn str_repr<'r>(&'a self) -> StrRepr<'r, 'a> { |
93 | 99 | StrRepr(self) |
94 | 100 | } |
@@ -265,18 +271,25 @@ pub struct AsciiEscape<'a> { |
265 | 271 | } |
266 | 272 |
|
267 | 273 | impl<'a> AsciiEscape<'a> { |
| 274 | + #[inline] |
268 | 275 | pub fn new(source: &'a [u8], layout: EscapeLayout) -> Self { |
269 | 276 | Self { source, layout } |
270 | 277 | } |
| 278 | + #[inline] |
271 | 279 | pub fn with_forced_quote(source: &'a [u8], quote: Quote) -> Self { |
272 | 280 | let layout = EscapeLayout { quote, len: None }; |
273 | 281 | Self { source, layout } |
274 | 282 | } |
275 | | - pub fn new_repr(source: &'a [u8]) -> Self { |
276 | | - let layout = Self::repr_layout(source, Quote::Single); |
| 283 | + #[inline] |
| 284 | + pub fn with_preferred_quote(source: &'a [u8], quote: Quote) -> Self { |
| 285 | + let layout = Self::repr_layout(source, quote); |
277 | 286 | Self { source, layout } |
278 | 287 | } |
279 | | - |
| 288 | + #[inline] |
| 289 | + pub fn new_repr(source: &'a [u8]) -> Self { |
| 290 | + Self::with_preferred_quote(source, Quote::Single) |
| 291 | + } |
| 292 | + #[inline] |
280 | 293 | pub fn bytes_repr<'r>(&'a self) -> BytesRepr<'r, 'a> { |
281 | 294 | BytesRepr(self) |
282 | 295 | } |
|
0 commit comments