simple_colour 1.0.4

A crate that allows programmers to change the style or colour of their strings
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
//! # simple_colour
//! `simple_colour` is a collection of functions providing a more conveniet
//! process to change output styles/colouring in the terminal
//!
//! It accepts both &str and String
//!
//! Use the [`Colour`] trait to style your strings.
//! ## Usage
//!
//! Add the trait to your scope:
//! ```
//! use simple_colour::Colour;
//!
//! println!("{}", "Hello World Italic".italic()); //Style
//! println!("{}", "Hello World Red".red()); //Colour
//! println!("{}", "Hello World Bold Red".red().bold()); // Can combine colours and styles
//! println!("{}", "Hello World Bright Blue".bright_blue());
//! println!("{}", "Hello World".truecolour(192)); //Yellowish green (Truecolour 8-bit format)
//! println!("{}", "Hello World".truecolour_rgb(0, 170, 170)); //Cyan (Truecolour rgb format)
//! println!("{}", "Hello World".bg_truecolour(192)); //Yellowish green background (Truecolour 8-bit format)
//! println!("{}", "Hello World".bg_truecolour_rgb(0, 170, 170)); //Cyan background (Truecolour rgb format)
//! println!("{}", "Hello Red Background".bg_red()); //Red background
//! println!("{}", "Hello Rainbow".rainbow()); // Produces rainbow text
//! 
//! //Reset
//! 
//! let mut str = "Hello world".red().bold();
//! str = str.reset();
//! println!("{}",str);
//! 
//! // Or
//! 
//! let str = "Hello world".red().bold();
//! let str = str.reset();
//! println!("{}",str);
//! ```
//!
//! See the [`Colour`] trait for all the methods. All methods return a String.
use std::{
    borrow::Borrow,
    fmt:: Display,
};

pub(crate) const RESET: &str = "\x1b[0m";
pub(crate) const RESET_BOLD: &str = "\x1b[22m";
pub(crate) const RESET_ITALIC: &str = "\x1b[23m";

// Style
pub(crate) const BOLD: &str = "\x1b[1m";
pub(crate) const ITALIC: &str = "\x1b[3m";

// Standard Colours
pub(crate) const BLACK: &str = "\x1b[30m";
pub(crate) const RED: &str = "\x1b[31m";
pub(crate) const GREEN: &str = "\x1b[32m";
pub(crate) const YELLOW: &str = "\x1b[33m";
pub(crate) const BLUE: &str = "\x1b[34m";
pub(crate) const MAGENTA: &str = "\x1b[35m";
pub(crate) const CYAN: &str = "\x1b[36m";
pub(crate) const WHITE: &str = "\x1b[37m";

// Bright Colours
pub(crate) const BRIGHT_BLACK: &str = "\x1b[90m";
pub(crate) const BRIGHT_RED: &str = "\x1b[91m";
pub(crate) const BRIGHT_GREEN: &str = "\x1b[92m";
pub(crate) const BRIGHT_YELLOW: &str = "\x1b[93m";
pub(crate) const BRIGHT_BLUE: &str = "\x1b[94m";
pub(crate) const BRIGHT_MAGENTA: &str = "\x1b[95m";
pub(crate) const BRIGHT_CYAN: &str = "\x1b[96m";
pub(crate) const BRIGHT_WHITE: &str = "\x1b[97m";

// Background colours
pub(crate) const BG_BLACK: &str = "\x1b[40m";
pub(crate) const BG_RED: &str = "\x1b[41m";
pub(crate) const BG_GREEN: &str = "\x1b[42m";
pub(crate) const BG_YELLOW: &str = "\x1b[43m";
pub(crate) const BG_BLUE: &str = "\x1b[44m";
pub(crate) const BG_MAGENTA: &str = "\x1b[45m";
pub(crate) const BG_CYAN: &str = "\x1b[46m";
pub(crate) const BG_WHITE: &str = "\x1b[47m";

pub(crate) const BG_BRIGHT_BLACK: &str = "\x1b[100m";
pub(crate) const BG_BRIGHT_RED: &str = "\x1b[101m";
pub(crate) const BG_BRIGHT_GREEN: &str = "\x1b[102m";
pub(crate) const BG_BRIGHT_YELLOW: &str = "\x1b[103m";
pub(crate) const BG_BRIGHT_BLUE: &str = "\x1b[104m";
pub(crate) const BG_BRIGHT_MAGENTA: &str = "\x1b[105m";
pub(crate) const BG_BRIGHT_CYAN: &str = "\x1b[106m";
pub(crate) const BG_BRIGHT_WHITE: &str = "\x1b[107m";

// True Colours
pub(crate) const ORANGE: &str = "\x1b[38;5;208m";
pub(crate) const INDIGO: &str = "\x1b[38;5;63m";
pub(crate) const VIOLET: &str = "\x1b[38;5;129m";

#[allow(dead_code)]

pub trait Colour {
    // --- Style ---

    /// Sets the text style to **bold**.
    /// ```
    /// # use simple_colour::Colour;
    /// println!("{}", "Bold Text".bold());
    /// ```
    fn bold(&self) -> String;

    /// Sets the text style to *italic*.
    /// ```
    /// # use simple_colour::Colour;
    /// println!("{}", "Italic Text".italic());
    /// ```
    fn italic(&self) -> String;

    /// Removes the styles and colors 
    fn reset(&self) -> String;

    // --- Standard Foreground ---

    /// Changes the text colour to black.
    fn black(&self) -> String;

    /// Changes the text colour to red.
    fn red(&self) -> String;

    /// Changes the text colour to green.
    fn green(&self) -> String;

    /// Changes the text colour to yellow.
    fn yellow(&self) -> String;

    /// Changes the text colour to blue.
    fn blue(&self) -> String;

    /// Changes the text colour to magenta.
    fn magenta(&self) -> String;

    /// Changes the text colour to cyan.
    fn cyan(&self) -> String;

    /// Changes the text colour to white.
    fn white(&self) -> String;

    // --- Bright Foreground ---

    /// Changes the text colour to bright black (gray).
    fn bright_black(&self) -> String;

    /// Changes the text colour to bright red.
    fn bright_red(&self) -> String;

    /// Changes the text colour to bright green.
    fn bright_green(&self) -> String;

    /// Changes the text colour to bright yellow.
    fn bright_yellow(&self) -> String;

    /// Changes the text colour to bright blue.
    fn bright_blue(&self) -> String;

    /// Changes the text colour to bright magenta.
    fn bright_magenta(&self) -> String;

    /// Changes the text colour to bright cyan.
    fn bright_cyan(&self) -> String;

    /// Changes the text colour to bright white.
    fn bright_white(&self) -> String;

    // --- Standard Background ---

    /// Changes the background colour to black.
    fn bg_black(&self) -> String;

    /// Changes the background colour to red.
    fn bg_red(&self) -> String;

    /// Changes the background colour to green.
    fn bg_green(&self) -> String;

    /// Changes the background colour to yellow.
    fn bg_yellow(&self) -> String;

    /// Changes the background colour to blue.
    fn bg_blue(&self) -> String;

    /// Changes the background colour to magenta.
    fn bg_magenta(&self) -> String;

    /// Changes the background colour to cyan.
    fn bg_cyan(&self) -> String;

    /// Changes the background colour to white.
    fn bg_white(&self) -> String;

    // --- Bright Background ---

    /// Changes the background colour to bright black.
    fn bg_bright_black(&self) -> String;

    /// Changes the background colour to bright red.
    fn bg_bright_red(&self) -> String;

    /// Changes the background colour to bright green.
    fn bg_bright_green(&self) -> String;

    /// Changes the background colour to bright yellow.
    fn bg_bright_yellow(&self) -> String;

    /// Changes the background colour to bright blue.
    fn bg_bright_blue(&self) -> String;

    /// Changes the background colour to bright magenta.
    fn bg_bright_magenta(&self) -> String;

    /// Changes the background colour to bright cyan.
    fn bg_bright_cyan(&self) -> String;

    /// Changes the background colour to bright white.
    fn bg_bright_white(&self) -> String;

    // --- True Colours ---

    /// Changes the text colour to orange.
    fn orange(&self) -> String;

    /// Changes the text colour to indigo.
    fn indigo(&self) -> String;

    /// Changes the text colour to violet.
    fn violet(&self) -> String;

    // --- Custom Colours ---

    /// Applies a custom colour using RGB values.
    /// ```
    /// # use simple_colour::Colour;
    /// "Custom".truecolour_rgb(100, 200, 50);
    /// ```
    fn truecolour_rgb(&self, r: u8, g: u8, b: u8) -> String;

    /// Applies a custom colour using an 8-bit ANSI colour code (0-255).
    /// ```
    /// # use simple_colour::Colour;
    /// "ANSI 150".truecolour(150);
    /// ```
    fn truecolour(&self, code: u8) -> String;

    /// Applies a custom background-colour using RGB values.
    /// ```
    /// # use simple_colour::Colour;
    /// "Custom".bg_truecolour_rgb(100, 200, 50);
    /// ```
    fn bg_truecolour_rgb(&self, r: u8, g: u8, b: u8) -> String;

    /// Applies a custom background-colour using an 8-bit ANSI colour code (0-255).
    /// ```
    /// # use simple_colour::Colour;
    /// "ANSI 150".bg_truecolour(150);
    /// ```
    fn bg_truecolour(&self, code: u8) -> String;

    /// Cycles through a spectrum of colours for each character in the string.
    /// ```
    /// # use simple_colour::Colour;
    /// println!("{}", "Rainbow!".rainbow());
    /// ```
    fn rainbow(&self) -> String;
}
impl<T> Colour for T
where
    T: Borrow<str> + Display,
{
    fn bold(&self) -> String {
        format!("{}{}{}", BOLD, self, RESET_BOLD)
    }

    fn italic(&self) -> String {
        format!("{}{}{}", ITALIC, self, RESET_ITALIC)
    }

    fn reset(&self) -> String {
        let str: String = self.to_string();
    
        let mut result: String = String::new();
        let mut skip: bool = false;
        for c in str.chars() {
            if c == '\x1b' {
                skip = true;
            }
            if !skip {
                result.push(c);
            }
            if  c == 'm' && skip {
                skip = false;
            }

        }
        result
    }

    fn black(&self) -> String {
        format!("{}{}{}", BLACK, self, RESET)
    }
    fn red(&self) -> String {
        format!("{}{}{}", RED, self, RESET)
    }

    fn green(&self) -> String {
        format!("{}{}{}", GREEN, self, RESET)
    }

    fn yellow(&self) -> String {
        format!("{}{}{}", YELLOW, self, RESET)
    }

    fn blue(&self) -> String {
        format!("{}{}{}", BLUE, self, RESET)
    }

    fn magenta(&self) -> String {
        format!("{}{}{}", MAGENTA, self, RESET)
    }

    fn cyan(&self) -> String {
        format!("{}{}{}", CYAN, self, RESET)
    }

    fn white(&self) -> String {
        format!("{}{}{}", WHITE, self, RESET)
    }

    fn bright_black(&self) -> String {
        format!("{}{}{}", BRIGHT_BLACK, self, RESET)
    }

    fn bright_red(&self) -> String {
        format!("{}{}{}", BRIGHT_RED, self, RESET)
    }

    fn bright_green(&self) -> String {
        format!("{}{}{}", BRIGHT_GREEN, self, RESET)
    }

    fn bright_yellow(&self) -> String {
        format!("{}{}{}", BRIGHT_YELLOW, self, RESET)
    }

    fn bright_blue(&self) -> String {
        format!("{}{}{}", BRIGHT_BLUE, self, RESET)
    }

    fn bright_magenta(&self) -> String {
        format!("{}{}{}", BRIGHT_MAGENTA, self, RESET)
    }

    fn bright_cyan(&self) -> String {
        format!("{}{}{}", BRIGHT_CYAN, self, RESET)
    }

    fn bright_white(&self) -> String {
        format!("{}{}{}", BRIGHT_WHITE, self, RESET)
    }

    // --- Background Standard ---
    fn bg_black(&self) -> String {
        format!("{}{}{}", BG_BLACK, self, RESET)
    }
    fn bg_red(&self) -> String {
        format!("{}{}{}", BG_RED, self, RESET)
    }
    fn bg_green(&self) -> String {
        format!("{}{}{}", BG_GREEN, self, RESET)
    }
    fn bg_yellow(&self) -> String {
        format!("{}{}{}", BG_YELLOW, self, RESET)
    }
    fn bg_blue(&self) -> String {
        format!("{}{}{}", BG_BLUE, self, RESET)
    }
    fn bg_magenta(&self) -> String {
        format!("{}{}{}", BG_MAGENTA, self, RESET)
    }
    fn bg_cyan(&self) -> String {
        format!("{}{}{}", BG_CYAN, self, RESET)
    }
    fn bg_white(&self) -> String {
        format!("{}{}{}", BG_WHITE, self, RESET)
    }

    // --- Background Bright ---
    fn bg_bright_black(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_BLACK, self, RESET)
    }
    fn bg_bright_red(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_RED, self, RESET)
    }
    fn bg_bright_green(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_GREEN, self, RESET)
    }
    fn bg_bright_yellow(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_YELLOW, self, RESET)
    }
    fn bg_bright_blue(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_BLUE, self, RESET)
    }
    fn bg_bright_magenta(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_MAGENTA, self, RESET)
    }
    fn bg_bright_cyan(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_CYAN, self, RESET)
    }
    fn bg_bright_white(&self) -> String {
        format!("{}{}{}", BG_BRIGHT_WHITE, self, RESET)
    }

    // true colours

    fn orange(&self) -> String {
        format!("{}{}{}", ORANGE, self, RESET)
    }

    fn indigo(&self) -> String {
        format!("{}{}{}", INDIGO, self, RESET)
    }

    fn violet(&self) -> String {
        format!("{}{}{}", VIOLET, self, RESET)
    }

    fn truecolour_rgb(&self, r: u8, g: u8, b: u8) -> String {
        let true_colour: String = format!("{};{};{};{}m", "\x1b[38;2", r, g, b);
        format!("{}{}{}", true_colour, self, RESET)
    }

    fn truecolour(&self, code: u8) -> String {
        let true_colour: String = format!("{};{}m", "\x1b[38;5", code);
        format!("{}{}{}", true_colour, self, RESET)
    }

    fn bg_truecolour_rgb(&self, r: u8, g: u8, b: u8) -> String {
        let bg_true_colour: String = format!("{};{};{};{}m", "\x1b[48;2", r, g, b);
        format!("{}{}{}", bg_true_colour, self, RESET)
    }

    fn bg_truecolour(&self, code: u8) -> String {
        let bg_true_colour: String = format!("{};{}m", "\x1b[48;5", code);
        format!("{}{}{}", bg_true_colour, self, RESET)
    }

    fn rainbow(&self) -> String {
        let rainbow_colours = vec![
            BRIGHT_RED,
            ORANGE,
            BRIGHT_YELLOW,
            BRIGHT_GREEN,
            BRIGHT_BLUE,
            INDIGO,
            VIOLET,
        ];
        self.borrow()
            .chars()
            .enumerate()
            .map(|(i, c)| {
                let colour = rainbow_colours[i % rainbow_colours.len()];
                format!("{}{}{}", colour, c, RESET)
            })
            .collect()
    }
}

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn test_styles() {
        assert_eq!("test".bold(), format!("{}{}{}", BOLD, "test", RESET_BOLD));
        assert_eq!(
            "test".italic(),
            format!("{}{}{}", ITALIC, "test", RESET_ITALIC)
        );
    }

    #[test]
    fn test_standard_colors() {
        assert_eq!("test".black(), format!("{}{}{}", BLACK, "test", RESET));
        assert_eq!("test".red(), format!("{}{}{}", RED, "test", RESET));
        assert_eq!("test".green(), format!("{}{}{}", GREEN, "test", RESET));
        assert_eq!("test".yellow(), format!("{}{}{}", YELLOW, "test", RESET));
        assert_eq!("test".blue(), format!("{}{}{}", BLUE, "test", RESET));
        assert_eq!("test".magenta(), format!("{}{}{}", MAGENTA, "test", RESET));
        assert_eq!("test".cyan(), format!("{}{}{}", CYAN, "test", RESET));
        assert_eq!("test".white(), format!("{}{}{}", WHITE, "test", RESET));
    }

    #[test]
    fn test_bright_colors() {
        assert_eq!(
            "hi".bright_black(),
            format!("{}{}{}", BRIGHT_BLACK, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_red(),
            format!("{}{}{}", BRIGHT_RED, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_green(),
            format!("{}{}{}", BRIGHT_GREEN, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_yellow(),
            format!("{}{}{}", BRIGHT_YELLOW, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_blue(),
            format!("{}{}{}", BRIGHT_BLUE, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_magenta(),
            format!("{}{}{}", BRIGHT_MAGENTA, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_cyan(),
            format!("{}{}{}", BRIGHT_CYAN, "hi", RESET)
        );
        assert_eq!(
            "hi".bright_white(),
            format!("{}{}{}", BRIGHT_WHITE, "hi", RESET)
        );
    }

    #[test]
    fn test_background_standard() {
        assert_eq!("bg".bg_black(), format!("{}{}{}", BG_BLACK, "bg", RESET));
        assert_eq!("bg".bg_red(), format!("{}{}{}", BG_RED, "bg", RESET));
        assert_eq!("bg".bg_green(), format!("{}{}{}", BG_GREEN, "bg", RESET));
        assert_eq!("bg".bg_yellow(), format!("{}{}{}", BG_YELLOW, "bg", RESET));
        assert_eq!("bg".bg_blue(), format!("{}{}{}", BG_BLUE, "bg", RESET));
        assert_eq!(
            "bg".bg_magenta(),
            format!("{}{}{}", BG_MAGENTA, "bg", RESET)
        );
        assert_eq!("bg".bg_cyan(), format!("{}{}{}", BG_CYAN, "bg", RESET));
        assert_eq!("bg".bg_white(), format!("{}{}{}", BG_WHITE, "bg", RESET));
    }

    #[test]
    fn test_background_bright() {
        assert_eq!(
            "bg".bg_bright_black(),
            format!("{}{}{}", BG_BRIGHT_BLACK, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_red(),
            format!("{}{}{}", BG_BRIGHT_RED, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_green(),
            format!("{}{}{}", BG_BRIGHT_GREEN, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_yellow(),
            format!("{}{}{}", BG_BRIGHT_YELLOW, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_blue(),
            format!("{}{}{}", BG_BRIGHT_BLUE, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_magenta(),
            format!("{}{}{}", BG_BRIGHT_MAGENTA, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_cyan(),
            format!("{}{}{}", BG_BRIGHT_CYAN, "bg", RESET)
        );
        assert_eq!(
            "bg".bg_bright_white(),
            format!("{}{}{}", BG_BRIGHT_WHITE, "bg", RESET)
        );
    }

    #[test]
    fn test_extended_colors() {
        assert_eq!("!".orange(), format!("{}{}{}", ORANGE, "!", RESET));
        assert_eq!("!".indigo(), format!("{}{}{}", INDIGO, "!", RESET));
        assert_eq!("!".violet(), format!("{}{}{}", VIOLET, "!", RESET));
    }

    #[test]
    fn test_truecolor_logic() {
        println!("{}", "text".bg_truecolour(150));
        println!("{}", "text".bg_truecolour_rgb(255, 100, 50));

        // Testing 256-color mode (\x1b[38;5;Nm)
        let custom_code = "text".truecolour(150);
        assert_eq!(custom_code, "\x1b[38;5;150mtext\x1b[0m");

        // Testing RGB mode (\x1b[38;2;R;G;Bm)
        let rgb_code = "text".truecolour_rgb(255, 100, 50);
        assert_eq!(rgb_code, "\x1b[38;2;255;100;50mtext\x1b[0m");

        let bg_custom_code = "text".bg_truecolour(150);
        assert_eq!(bg_custom_code, "\x1b[48;5;150mtext\x1b[0m");

        let bg_rgb_code = "text".bg_truecolour_rgb(255, 100, 50);
        assert_eq!(bg_rgb_code, "\x1b[48;2;255;100;50mtext\x1b[0m");
    }

    #[test]
    fn test_rainbow() {
        let input = "ABC";
        let result = input.rainbow();

        // "A" should be Bright Red, "B" Orange, "C" Bright Yellow
        let expected = format!(
            "{}{}{}{}{}{}{}{}{}",
            BRIGHT_RED, "A", RESET, ORANGE, "B", RESET, BRIGHT_YELLOW, "C", RESET
        );
        assert_eq!(result, expected);
    }

    #[test]
    fn test_generic_support() {
        // Test that it works on an owned String as well as &str
        let owned = String::from("owned");
        assert_eq!(owned.red(), format!("{}{}{}", RED, "owned", RESET));
    }

    #[test]
    fn test_reset(){
        let str = "Hello".red().bold();
        
        assert_eq!(str.reset(),"Hello")
    }
}