Struct nu_ansi_term::AnsiGenericString
source · 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>
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.
source§impl<'a, S: PartialEq + 'a + ToOwned + ?Sized> PartialEq for AnsiGenericString<'a, S>
impl<'a, S: PartialEq + 'a + ToOwned + ?Sized> PartialEq for AnsiGenericString<'a, S>
source§fn eq(&self, other: &AnsiGenericString<'a, S>) -> bool
fn eq(&self, other: &AnsiGenericString<'a, S>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)