Skip to content

Commit c425666

Browse files
tamirddjc
authored andcommitted
Make functions on Style const
1 parent 95279d7 commit c425666

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

src/utils.rs

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ impl Default for Style {
173173

174174
impl Style {
175175
/// Returns an empty default style.
176-
pub fn new() -> Self {
176+
pub const fn new() -> Self {
177177
Self {
178178
fg: None,
179179
bg: None,
@@ -253,14 +253,14 @@ impl Style {
253253
///
254254
/// This overrides the automatic detection.
255255
#[inline]
256-
pub fn force_styling(mut self, value: bool) -> Self {
256+
pub const fn force_styling(mut self, value: bool) -> Self {
257257
self.force = Some(value);
258258
self
259259
}
260260

261261
/// Specifies that style is applying to something being written on stderr.
262262
#[inline]
263-
pub fn for_stderr(mut self) -> Self {
263+
pub const fn for_stderr(mut self) -> Self {
264264
self.for_stderr = true;
265265
self
266266
}
@@ -269,21 +269,21 @@ impl Style {
269269
///
270270
/// This is the default behaviour.
271271
#[inline]
272-
pub fn for_stdout(mut self) -> Self {
272+
pub const fn for_stdout(mut self) -> Self {
273273
self.for_stderr = false;
274274
self
275275
}
276276

277277
/// Sets a foreground color.
278278
#[inline]
279-
pub fn fg(mut self, color: Color) -> Self {
279+
pub const fn fg(mut self, color: Color) -> Self {
280280
self.fg = Some(color);
281281
self
282282
}
283283

284284
/// Sets a background color.
285285
#[inline]
286-
pub fn bg(mut self, color: Color) -> Self {
286+
pub const fn bg(mut self, color: Color) -> Self {
287287
self.bg = Some(color);
288288
self
289289
}
@@ -296,87 +296,87 @@ impl Style {
296296
}
297297

298298
#[inline]
299-
pub fn black(self) -> Self {
299+
pub const fn black(self) -> Self {
300300
self.fg(Color::Black)
301301
}
302302
#[inline]
303-
pub fn red(self) -> Self {
303+
pub const fn red(self) -> Self {
304304
self.fg(Color::Red)
305305
}
306306
#[inline]
307-
pub fn green(self) -> Self {
307+
pub const fn green(self) -> Self {
308308
self.fg(Color::Green)
309309
}
310310
#[inline]
311-
pub fn yellow(self) -> Self {
311+
pub const fn yellow(self) -> Self {
312312
self.fg(Color::Yellow)
313313
}
314314
#[inline]
315-
pub fn blue(self) -> Self {
315+
pub const fn blue(self) -> Self {
316316
self.fg(Color::Blue)
317317
}
318318
#[inline]
319-
pub fn magenta(self) -> Self {
319+
pub const fn magenta(self) -> Self {
320320
self.fg(Color::Magenta)
321321
}
322322
#[inline]
323-
pub fn cyan(self) -> Self {
323+
pub const fn cyan(self) -> Self {
324324
self.fg(Color::Cyan)
325325
}
326326
#[inline]
327-
pub fn white(self) -> Self {
327+
pub const fn white(self) -> Self {
328328
self.fg(Color::White)
329329
}
330330
#[inline]
331-
pub fn color256(self, color: u8) -> Self {
331+
pub const fn color256(self, color: u8) -> Self {
332332
self.fg(Color::Color256(color))
333333
}
334334

335335
#[inline]
336-
pub fn bright(mut self) -> Self {
336+
pub const fn bright(mut self) -> Self {
337337
self.fg_bright = true;
338338
self
339339
}
340340

341341
#[inline]
342-
pub fn on_black(self) -> Self {
342+
pub const fn on_black(self) -> Self {
343343
self.bg(Color::Black)
344344
}
345345
#[inline]
346-
pub fn on_red(self) -> Self {
346+
pub const fn on_red(self) -> Self {
347347
self.bg(Color::Red)
348348
}
349349
#[inline]
350-
pub fn on_green(self) -> Self {
350+
pub const fn on_green(self) -> Self {
351351
self.bg(Color::Green)
352352
}
353353
#[inline]
354-
pub fn on_yellow(self) -> Self {
354+
pub const fn on_yellow(self) -> Self {
355355
self.bg(Color::Yellow)
356356
}
357357
#[inline]
358-
pub fn on_blue(self) -> Self {
358+
pub const fn on_blue(self) -> Self {
359359
self.bg(Color::Blue)
360360
}
361361
#[inline]
362-
pub fn on_magenta(self) -> Self {
362+
pub const fn on_magenta(self) -> Self {
363363
self.bg(Color::Magenta)
364364
}
365365
#[inline]
366-
pub fn on_cyan(self) -> Self {
366+
pub const fn on_cyan(self) -> Self {
367367
self.bg(Color::Cyan)
368368
}
369369
#[inline]
370-
pub fn on_white(self) -> Self {
370+
pub const fn on_white(self) -> Self {
371371
self.bg(Color::White)
372372
}
373373
#[inline]
374-
pub fn on_color256(self, color: u8) -> Self {
374+
pub const fn on_color256(self, color: u8) -> Self {
375375
self.bg(Color::Color256(color))
376376
}
377377

378378
#[inline]
379-
pub fn on_bright(mut self) -> Self {
379+
pub const fn on_bright(mut self) -> Self {
380380
self.bg_bright = true;
381381
self
382382
}

0 commit comments

Comments
 (0)