pub struct AnsiGenericString<'a, S: 'a + ToOwned + ?Sized>{ /* private fields */ }
Expand description
An AnsiGenericString
includes a generic string type and a Style
to
display that string. AnsiString
and AnsiByteString
are aliases for
this type on str
and \[u8]
, respectively.
Implementations§
Source§impl<'a, S: 'a + ToOwned + ?Sized> AnsiGenericString<'a, S>
impl<'a, S: 'a + ToOwned + ?Sized> AnsiGenericString<'a, S>
Sourcepub fn style_ref_mut(&mut self) -> &mut Style
pub fn style_ref_mut(&mut self) -> &mut Style
Directly access the style mutably
Sourcepub fn title<I>(s: I) -> Self
pub fn title<I>(s: I) -> Self
Produce an ANSI string that changes the title shown by the terminal emulator.
§Examples
use nu_ansi_term::AnsiGenericString;
let title_string = AnsiGenericString::title("My Title");
println!("{}", title_string);
Should produce an empty line but set the terminal title.
Sourcepub fn hyperlink<I>(self, url: I) -> Self
pub fn hyperlink<I>(self, url: I) -> Self
Cause the styled ANSI string to link to the given URL
§Examples
use nu_ansi_term::Color::Red;
let link_string = Red.paint("a red string").hyperlink("https://www.example.com");
println!("{}", link_string);
Should show a red-painted string which, on terminals that support it, is a clickable hyperlink.
Sourcepub fn url_string(&self) -> Option<&S>
pub fn url_string(&self) -> Option<&S>
Get any URL associated with the string
Trait Implementations§
Source§impl<'a, S: 'a + ToOwned + ?Sized> Clone for AnsiGenericString<'a, S>
Cloning an AnsiGenericString
will clone its underlying string.
impl<'a, S: 'a + ToOwned + ?Sized> Clone for AnsiGenericString<'a, S>
Cloning an AnsiGenericString
will clone its underlying string.
§Examples
use nu_ansi_term::AnsiString;
let plain_string = AnsiString::from("a plain string");
let clone_string = plain_string.clone();
assert_eq!(clone_string, plain_string);
Source§fn clone(&self) -> AnsiGenericString<'a, S>
fn clone(&self) -> AnsiGenericString<'a, S>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<'a, I, S: 'a + ToOwned + ?Sized> From<I> for AnsiGenericString<'a, S>
impl<'a, I, S: 'a + ToOwned + ?Sized> From<I> for AnsiGenericString<'a, S>
Source§fn from(input: I) -> AnsiGenericString<'a, S>
fn from(input: I) -> AnsiGenericString<'a, S>
Converts to this type from the input type.
impl<'a, S: Eq + 'a + ToOwned + ?Sized> Eq for AnsiGenericString<'a, S>
impl<'a, S: 'a + ToOwned + ?Sized> StructuralPartialEq for AnsiGenericString<'a, S>
Auto Trait Implementations§
impl<'a, S> Freeze for AnsiGenericString<'a, S>
impl<'a, S> RefUnwindSafe for AnsiGenericString<'a, S>
impl<'a, S> Send for AnsiGenericString<'a, S>
impl<'a, S> Sync for AnsiGenericString<'a, S>
impl<'a, S> Unpin for AnsiGenericString<'a, S>
impl<'a, S> UnwindSafe for AnsiGenericString<'a, S>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more