Struct octicons::Octicon

source ·
pub struct Octicon { /* private fields */ }
Expand description

Structure for Octicon configuration.

Implementations§

source§

impl Octicon

source

pub fn width<'a>(&'a mut self, width: usize) -> &'a mut Octicon

Set the width attribute of the <svg> element. The height attribute will not be scaled automatically.

let dash = format!("{}", DASH.clone().width(32));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="32" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
source

pub fn height<'a>(&'a mut self, height: usize) -> &'a mut Octicon

Set the height attribute of the <svg> element. The width attribute will not be scaled automatically.

let dash = format!("{}", DASH.clone().height(48));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="48" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
source

pub fn class<'a>(&'a mut self, class: Option<&'static str>) -> &'a mut Octicon

Set the class attribute of the <svg> element. To prevent the attribute from being rendered, set it to None.

let dash = format!("{}", DASH.clone().class(None));
let expected = r#"<svg version="1.1" aria-hidden="true" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().class(Some("left right")));
let expected = r#"<svg version="1.1" aria-hidden="true" class="left right" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);
source

pub fn fill<'a>(&'a mut self, fill: Option<&'static str>) -> &'a mut Octicon

Set the fill attribute of the <svg>. To prevent the attribute from being rendered, set it to None.

let dash = format!("{}", DASH.clone().fill(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().fill(Some("#ff0")));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" fill="#ff0" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
source

pub fn xmlns<'a>(&'a mut self, xmlns: Option<&'static str>) -> &'a mut Octicon

Set the xmlns attribute of the <svg>. To prevent the attribute from being rendered, set it to None. NOTE: the xmlns attribute is required by some browsers if the svg is served alone. If the svg element will be part of an HTML document then you can omit the xmlns attribute.

let dash = format!("{}", DASH.clone().xmlns(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().xmlns(Some("http://www.w3.org/2000/svg")));
let expected = r##"<svg xmlns="http://www.w3.org/2000/svg" version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
source

pub fn version<'a>( &'a mut self, version: Option<&'static str> ) -> &'a mut Octicon

Set the version attribute of the <svg>. To prevent the attribute from being rendered, set it to None. NOTE: the version attribute is apparently ignored by every user agent. If you want to save some bandwidth you are probably safe omitting it until the release of further major versions.

let dash = format!("{}", DASH.clone().version(None));
let expected = r#"<svg aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().version(Some("1.1")));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
source

pub fn aria_label<'a>( &'a mut self, aria_label: Option<&'static str> ) -> &'a mut Octicon

Set an aria-label on the <svg>. To prevent the attribute from being rendered, set it to None. If the aria-label is set, then the aria-hidden attribute is not rendered regardless of its value. Additionally the role attribute will be set to img.

let dash = format!("{}", DASH.clone().aria_label(None));
let expected = r#"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().aria_label(Some("dash")));
let expected = r##"<svg version="1.1" aria-label="dash" role="img" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);
source

pub fn aria_hidden<'a>(&'a mut self, aria_hidden: bool) -> &'a mut Octicon

Set an aria-hidden attribute on the <svg>. To prevent the attribute from being rendered, set it to false. If the aria-label is set, then the aria-hidden attribute is not rendered regardless of its value.

let dash = format!("{}", DASH.clone().aria_hidden(false));
let expected = r#"<svg version="1.1" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"#;
assert_eq!(expected, dash);

let dash = format!("{}", DASH.clone().aria_hidden(true));
let expected = r##"<svg version="1.1" aria-hidden="true" class="octicon octicon-dash" width="8" height="16" viewBox="0 0 8 16"><path fill-rule="evenodd" d="M0 7v2h8V7z"/></svg>"##;
assert_eq!(expected, dash);

Trait Implementations§

source§

impl Clone for Octicon

source§

fn clone(&self) -> Octicon

Returns a copy 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 Display for Octicon

source§

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

Formats the value using the given formatter. Read more
source§

impl Copy for Octicon

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

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

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

§

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 Twhere U: TryFrom<T>,

§

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.