Skip to content

Commit

Permalink
fmt & #[inline(always)]s
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza1311 committed Apr 11, 2022
1 parent 6a24780 commit 6b1a1fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
3 changes: 1 addition & 2 deletions packages/yew/src/dom_bundle/btag/attributes.rs
Expand Up @@ -90,8 +90,7 @@ impl Attributes {
mut new_iter: impl Iterator<Item = (&'a str, &'a str)>,
new: &IndexMap<AttrValue, AttrValue>,
old: &IndexMap<AttrValue, AttrValue>,
)
{
) {
let mut old_iter = old.iter();
let new = new
.iter()
Expand Down
8 changes: 8 additions & 0 deletions packages/yew/src/virtual_dom/mod.rs
Expand Up @@ -58,6 +58,7 @@ pub enum AttrValue {
impl Deref for AttrValue {
type Target = str;

#[inline(always)]
fn deref(&self) -> &Self::Target {
match self {
AttrValue::Static(s) => *s,
Expand All @@ -67,6 +68,7 @@ impl Deref for AttrValue {
}

impl Hash for AttrValue {
#[inline(always)]
fn hash<H: Hasher>(&self, state: &mut H) {
match self {
AttrValue::Static(s) => s.hash(&mut *state),
Expand All @@ -76,24 +78,28 @@ impl Hash for AttrValue {
}

impl From<&'static str> for AttrValue {
#[inline(always)]
fn from(s: &'static str) -> Self {
AttrValue::Static(s)
}
}

impl From<String> for AttrValue {
#[inline(always)]
fn from(s: String) -> Self {
AttrValue::Rc(Rc::from(s))
}
}

impl From<Rc<str>> for AttrValue {
#[inline(always)]
fn from(s: Rc<str>) -> Self {
AttrValue::Rc(s)
}
}

impl From<Cow<'static, str>> for AttrValue {
#[inline(always)]
fn from(s: Cow<'static, str>) -> Self {
match s {
Cow::Borrowed(s) => s.into(),
Expand All @@ -112,6 +118,7 @@ impl Clone for AttrValue {
}

impl AsRef<str> for AttrValue {
#[inline(always)]
fn as_ref(&self) -> &str {
&*self
}
Expand All @@ -127,6 +134,7 @@ impl fmt::Display for AttrValue {
}

impl PartialEq for AttrValue {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.as_ref() == other.as_ref()
}
Expand Down

0 comments on commit 6b1a1fc

Please sign in to comment.