Struct ColouredStr

Source
pub struct ColouredStr<'a> {
    pub string: &'a str,
    pub coloured_string: String,
    /* private fields */
}
Expand description

This struct is the main way to utilize the coloring sceme in this crate.

This struct contains a number of parameters inquiring to the strings state, such as style,color,base string, reset actions, background and several internal things. this structs, as it say’s below implements the fmt::Display trait, that means that you will not need to do anything special in order to print after you have changed the color you can use only one color but you can have even all the styles together!

here is a blue,bold,underlined and blinking string example(just a fromatted output) :

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blue();
str1.bold();
str1.underline();
str1.blink();
let str2 = format!("{}{}{}","\u{1b}[1;4;5;49;34m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);

here is a white,bold and hidden string example(good for passwords):

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.white();
str1.bold();
str1.hidden();
let str2 = format!("{}{}{}","\u{1b}[1;8;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);

Fields§

§string: &'a str§coloured_string: String

Implementations§

Source§

impl<'a> ColouredStr<'a>

Source

pub fn new(string: &str) -> ColouredStr<'_>

This functions recieves one parameter - a string and creates a defult struct for it. the color is natural(no change), as well as the styles and background.

use ansi_colors::*;
let str1 = ColouredStr::new("hello world");
assert_eq!(str1.string,"hello world");
Examples found in repository?
examples/error1/main.rs (line 4)
3fn main(){
4    let mut str1 = ColouredStr::new("ERROR!!!");
5    str1.to_error();
6    println!("{}",str1);
7}
More examples
Hide additional examples
examples/red_bold_blink/main.rs (line 3)
2fn main(){
3    let mut str1 = ColouredStr::new("hello world");
4    str1.red();
5    str1.bold();
6    str1.blink();
7    println!("{}",str1);
8}
examples/hidden/main.rs (line 3)
2fn main(){
3    let mut pass = ColouredStr::new("ansi_coloring");
4    pass.white();
5    pass.bold();
6    pass.hidden();
7    println!("{}",pass);
8}
examples/basic_blue/main.rs (line 3)
2fn main(){
3    let mut str1 = ColouredStr::new("hello ansi");
4    str1.blue()
5        .bold().underline();
6    println!("{}",&str1.coloured_string[1..]);
7}
examples/black_screen/main.rs (line 3)
2fn main(){
3    let mut str1 = ColouredStr::new("string1sdaasdsdasda\nsdasdasdasd\nadasds");
4    str1.green();
5    str1.bold();
6    str1.back_black();
7    println!("{}",str1);
8
9}
Source

pub fn to_error(&mut self)

This functions takes self and presents the color string in error format

Examples found in repository?
examples/error1/main.rs (line 5)
3fn main(){
4    let mut str1 = ColouredStr::new("ERROR!!!");
5    str1.to_error();
6    println!("{}",str1);
7}
Source

pub fn to_success(&mut self)

This functions takes self and presents the color string in success format

Source

pub fn to_password(&mut self)

This functions takes self and presents the color string in password format

Source

pub fn blue(&mut self) -> Self

This functions takes self and changes coloured string color into blue

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blue();
let str2 = format!("{}{}{}","\u{1b}[49;34m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/basic_blue/main.rs (line 4)
2fn main(){
3    let mut str1 = ColouredStr::new("hello ansi");
4    str1.blue()
5        .bold().underline();
6    println!("{}",&str1.coloured_string[1..]);
7}
Source

pub fn black(&mut self)

This functions takes self and changes coloured string color into black

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
let str2 = format!("{}{}{}","\u{1b}[49;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn red(&mut self)

This functions takes self and changes coloured string color into red

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
let str2 = format!("{}{}{}","\u{1b}[49;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/red_bold_blink/main.rs (line 4)
2fn main(){
3    let mut str1 = ColouredStr::new("hello world");
4    str1.red();
5    str1.bold();
6    str1.blink();
7    println!("{}",str1);
8}
Source

pub fn green(&mut self)

This functions takes self and changes coloured string color into green

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.green();
let str2 = format!("{}{}{}","\u{1b}[49;32m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/black_screen/main.rs (line 4)
2fn main(){
3    let mut str1 = ColouredStr::new("string1sdaasdsdasda\nsdasdasdasd\nadasds");
4    str1.green();
5    str1.bold();
6    str1.back_black();
7    println!("{}",str1);
8
9}
Source

pub fn yellow(&mut self)

This functions takes self and changes coloured string color into yellow

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.yellow();
let str2 = format!("{}{}{}","\u{1b}[49;33m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn magenta(&mut self)

This functions takes self and changes coloured string color into magenta

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.magenta();
let str2 = format!("{}{}{}","\u{1b}[49;35m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn cyan(&mut self)

This functions takes self and changes coloured string color into cyan

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.cyan();
let str2 = format!("{}{}{}","\u{1b}[49;36m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn gray(&mut self)

This functions takes self and changes coloured string color into gray

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.gray();
let str2 = format!("{}{}{}","\u{1b}[49;37m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn dark_gray(&mut self)

This functions takes self and changes coloured string color into dark gray

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.dark_gray();
let str2 = format!("{}{}{}","\u{1b}[49;90m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn light_red(&mut self)

This functions takes self and changes coloured string color into light red

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.light_red();
let str2 = format!("{}{}{}","\u{1b}[49;91m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn light_green(&mut self)

This functions takes self and changes coloured string color into light green

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.light_green();
let str2 = format!("{}{}{}","\u{1b}[49;92m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn light_yellow(&mut self)

This functions takes self and changes coloured string color into light yellow

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.light_yellow();
let str2 = format!("{}{}{}","\u{1b}[49;93m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn light_blue(&mut self)

This functions takes self and changes coloured string color into light blue

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.light_blue();
let str2 = format!("{}{}{}","\u{1b}[49;94m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn pink(&mut self)

This functions takes self and changes coloured string color into pink

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.pink();
let str2 = format!("{}{}{}","\u{1b}[49;95m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn light_cyan(&mut self)

This functions takes self and changes coloured string color into light cyan

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.light_cyan();
let str2 = format!("{}{}{}","\u{1b}[49;96m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn white(&mut self)

This functions takes self and changes coloured string color into white

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.white();
let str2 = format!("{}{}{}","\u{1b}[49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/hidden/main.rs (line 4)
2fn main(){
3    let mut pass = ColouredStr::new("ansi_coloring");
4    pass.white();
5    pass.bold();
6    pass.hidden();
7    println!("{}",pass);
8}
Source

pub fn none(&mut self)

This functions takes self and resets the string’s color

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.none();
let str2 = format!("{}{}{}","\u{1b}[49;39m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn bold(&mut self) -> Self

This functions takes self and adds the bold style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.bold();
let str2 = format!("{}{}{}","\u{1b}[1;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/red_bold_blink/main.rs (line 5)
2fn main(){
3    let mut str1 = ColouredStr::new("hello world");
4    str1.red();
5    str1.bold();
6    str1.blink();
7    println!("{}",str1);
8}
More examples
Hide additional examples
examples/hidden/main.rs (line 5)
2fn main(){
3    let mut pass = ColouredStr::new("ansi_coloring");
4    pass.white();
5    pass.bold();
6    pass.hidden();
7    println!("{}",pass);
8}
examples/basic_blue/main.rs (line 5)
2fn main(){
3    let mut str1 = ColouredStr::new("hello ansi");
4    str1.blue()
5        .bold().underline();
6    println!("{}",&str1.coloured_string[1..]);
7}
examples/black_screen/main.rs (line 5)
2fn main(){
3    let mut str1 = ColouredStr::new("string1sdaasdsdasda\nsdasdasdasd\nadasds");
4    str1.green();
5    str1.bold();
6    str1.back_black();
7    println!("{}",str1);
8
9}
Source

pub fn dim(&mut self)

This functions takes self and adds the dim style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.dim();
let str2 = format!("{}{}{}","\u{1b}[2;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn underline(&mut self) -> Self

This functions takes self and adds the underline style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.underline();
let str2 = format!("{}{}{}","\u{1b}[4;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/basic_blue/main.rs (line 5)
2fn main(){
3    let mut str1 = ColouredStr::new("hello ansi");
4    str1.blue()
5        .bold().underline();
6    println!("{}",&str1.coloured_string[1..]);
7}

This functions takes self and adds the blinking style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blink();
let str2 = format!("{}{}{}","\u{1b}[5;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/red_bold_blink/main.rs (line 6)
2fn main(){
3    let mut str1 = ColouredStr::new("hello world");
4    str1.red();
5    str1.bold();
6    str1.blink();
7    println!("{}",str1);
8}
Source

pub fn reverse(&mut self)

This functions takes self and adds the reverse style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.reverse();
let str2 = format!("{}{}{}","\u{1b}[7;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn hidden(&mut self)

This functions takes self and adds the hidden( ) style to the string

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.hidden();
let str2 = format!("{}{}{}","\u{1b}[8;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/hidden/main.rs (line 6)
2fn main(){
3    let mut pass = ColouredStr::new("ansi_coloring");
4    pass.white();
5    pass.bold();
6    pass.hidden();
7    println!("{}",pass);
8}
Source

pub fn back_black(&mut self)

This functions takes self and changes the background to be black

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.white();
str1.back_black();
let str2 = format!("{}{}{}","\u{1b}[40;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Examples found in repository?
examples/black_screen/main.rs (line 6)
2fn main(){
3    let mut str1 = ColouredStr::new("string1sdaasdsdasda\nsdasdasdasd\nadasds");
4    str1.green();
5    str1.bold();
6    str1.back_black();
7    println!("{}",str1);
8
9}
Source

pub fn back_red(&mut self)

This functions takes self and changes the background to be red

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blue();
str1.back_red();
let str2 = format!("{}{}{}","\u{1b}[41;34m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_blue(&mut self)

This functions takes self and changes the background to be blue

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_blue();
let str2 = format!("{}{}{}","\u{1b}[44;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_green(&mut self)

This functions takes self and changes the background to be green

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_green();
let str2 = format!("{}{}{}","\u{1b}[42;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_yellow(&mut self)

This functions takes self and changes the background to be yellow

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.magenta();
str1.back_yellow();
let str2 = format!("{}{}{}","\u{1b}[43;35m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_magenta(&mut self)

This functions takes self and changes the background to be magenta

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
str1.back_magenta();
let str2 = format!("{}{}{}","\u{1b}[45;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_cyan(&mut self)

This functions takes self and changes the background to be cyan

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_cyan();
let str2 = format!("{}{}{}","\u{1b}[46;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_gray(&mut self)

This functions takes self and changes the background to be gray

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.yellow();
str1.back_gray();
let str2 = format!("{}{}{}","\u{1b}[47;33m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_dark_gray(&mut self)

This functions takes self and changes the background to be dark gray

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.white();
str1.back_dark_gray();
let str2 = format!("{}{}{}","\u{1b}[100;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_light_red(&mut self)

This functions takes self and changes the background to be light red

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
str1.back_light_red();
let str2 = format!("{}{}{}","\u{1b}[101;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_light_green(&mut self)

This functions takes self and changes the background to be light green

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_light_green();
let str2 = format!("{}{}{}","\u{1b}[102;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_light_yellow(&mut self)

This functions takes self and changes the background to be light yellow

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blue();
str1.back_light_yellow();
let str2 = format!("{}{}{}","\u{1b}[103;34m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_light_blue(&mut self)

This functions takes self and changes the background to be light blue

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
str1.back_light_blue();
let str2 = format!("{}{}{}","\u{1b}[104;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_pink(&mut self)

This functions takes self and changes the background to be pink

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
str1.back_pink();
let str2 = format!("{}{}{}","\u{1b}[105;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_light_cyan(&mut self)

This functions takes self and changes the background to be light cyan

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_light_green();
let str2 = format!("{}{}{}","\u{1b}[102;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_white(&mut self)

This functions takes self and changes the background to be white

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.black();
str1.back_white();
let str2 = format!("{}{}{}","\u{1b}[107;30m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn back_none(&mut self)

This functions takes self and changes the background to be none

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.red();
str1.back_none();
let str2 = format!("{}{}{}","\u{1b}[49;31m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_all(&mut self)

This functions takes self and adds the reset all operation to the reset

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blink();
str1.reset_all();
let str2 = format!("{}{}{}","\u{1b}[5;49;97m","hello world","\u{1b}[0m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_bold(&mut self)

This functions takes self and adds the reset bold operation to the reset it means it resets only the bold style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.bold();
str1.red();
str1.reset_bold();
let str2 = format!("{}{}{}","\u{1b}[1;49;31m","hello world","\u{1b}[21m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_dim(&mut self)

This functions takes self and adds the reset dim operation to the reset it means it resets only the dim style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.dim();
str1.bold();
str1.reset_dim();
let str2 = format!("{}{}{}","\u{1b}[2;1;49;97m","hello world","\u{1b}[22m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_underline(&mut self)

This functions takes self and adds the reset underline operation to the reset it means it resets only the underline style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.underline();
str1.back_green();
str1.reset_underline();
let str2 = format!("{}{}{}","\u{1b}[4;42;97m","hello world","\u{1b}[24m");
assert_eq!(str1.coloured_string,str2);

This functions takes self and adds the reset blink operation to the reset it means it resets only the blink style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.blink();
str1.red();
str1.reset_blink();
let str2 = format!("{}{}{}","\u{1b}[5;49;31m","hello world","\u{1b}[25m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_reverse(&mut self)

This functions takes self and adds the reset reverse operation to the reset it means it resets only the reverse style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.reverse();
str1.back_red();
str1.reset_reverse();
let str2 = format!("{}{}{}","\u{1b}[7;41;97m","hello world","\u{1b}[27m");
assert_eq!(str1.coloured_string,str2);
Source

pub fn reset_hidden(&mut self)

This functions takes self and adds the reset hidden operation to the reset it means it resets only the hidden style, not any other active styles or colors.

use ansi_colors::*;
let mut str1 = ColouredStr::new("hello world");
str1.hidden();
str1.back_black();
str1.reset_hidden();
let str2 = format!("{}{}{}","\u{1b}[8;40;97m","hello world","\u{1b}[28m");
assert_eq!(str1.coloured_string,str2);

Trait Implementations§

Source§

impl<'a> Clone for ColouredStr<'a>

Source§

fn clone(&self) -> ColouredStr<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Display for ColouredStr<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ColouredStr<'a>

§

impl<'a> RefUnwindSafe for ColouredStr<'a>

§

impl<'a> Send for ColouredStr<'a>

§

impl<'a> Sync for ColouredStr<'a>

§

impl<'a> Unpin for ColouredStr<'a>

§

impl<'a> UnwindSafe for ColouredStr<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.