Skip to content

Commit a18adaa

Browse files
authored
fix: remove unstable config-include hack now that include is stable in Rust 1.94 (#4050)
1 parent 2a4820a commit a18adaa

6 files changed

Lines changed: 32 additions & 35 deletions

File tree

examples/function_router/src/components/pagination.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ pub fn Links(props: &Props) -> Html {
131131
page, total_pages, ..
132132
} = *props;
133133

134-
let pages_prev = page.checked_sub(1).unwrap_or_default() as usize;
134+
let pages_prev = page.saturating_sub(1) as usize;
135135
let pages_next = (total_pages - page) as usize;
136136

137137
let links_left = LINKS_PER_SIDE.min(pages_prev)
138138
// if there are less than `LINKS_PER_SIDE` to the right, we add some more on the left.
139-
+ LINKS_PER_SIDE.checked_sub(pages_next).unwrap_or_default();
139+
+ LINKS_PER_SIDE.saturating_sub(pages_next);
140140
let links_right = 2 * LINKS_PER_SIDE - links_left;
141141

142142
html! {

examples/keyed_list/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ impl Component for App {
106106
true
107107
}
108108
Msg::SortById => {
109-
self.persons
110-
.sort_unstable_by(|a, b| a.info().id.cmp(&b.info().id));
109+
self.persons.sort_unstable_by_key(|a| a.info().id);
111110
true
112111
}
113112
Msg::SortByName => {

examples/router/src/components/pagination.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ impl Pagination {
9595
page, total_pages, ..
9696
} = *props;
9797

98-
let pages_prev = page.checked_sub(1).unwrap_or_default() as usize;
98+
let pages_prev = page.saturating_sub(1) as usize;
9999
let pages_next = (total_pages - page) as usize;
100100

101101
let links_left = LINKS_PER_SIDE.min(pages_prev)
102102
// if there are less than `LINKS_PER_SIDE` to the right, we add some more on the left.
103-
+ LINKS_PER_SIDE.checked_sub(pages_next).unwrap_or_default();
103+
+ LINKS_PER_SIDE.saturating_sub(pages_next);
104104
let links_right = 2 * LINKS_PER_SIDE - links_left;
105105

106106
html! {

packages/yew-macro/src/html_tree/tag.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,12 @@ impl TagTokens {
107107
let next = input.parse()?;
108108
if let TokenTree::Punct(punct) = &next {
109109
match punct.as_char() {
110-
'/' => {
111-
if angle_count == 1 && input.peek(Token![>]) {
112-
div = Some(syn::token::Slash {
113-
spans: [punct.span()],
114-
});
115-
gt = input.parse()?;
116-
break;
117-
}
110+
'/' if angle_count == 1 && input.peek(Token![>]) => {
111+
div = Some(syn::token::Slash {
112+
spans: [punct.span()],
113+
});
114+
gt = input.parse()?;
115+
break;
118116
}
119117
'>' => {
120118
angle_count = angle_count.checked_sub(1).ok_or_else(|| {

packages/yew/src/dom_bundle/btag/mod.rs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,19 +175,20 @@ impl Reconcilable for VTag {
175175
match bundle {
176176
// If the ancestor is a tag of the same type, don't recreate, keep the
177177
// old tag and update its attributes and children.
178-
BNode::Tag(ex) if self.key == ex.key => {
179-
if match (&self.inner, &ex.inner) {
180-
(VTagInner::Input(_), BTagInner::Input(_)) => true,
181-
(VTagInner::Textarea { .. }, BTagInner::Textarea { .. }) => true,
182-
(VTagInner::Other { tag: l, .. }, BTagInner::Other { tag: r, .. })
183-
if l == r =>
184-
{
185-
true
186-
}
187-
_ => false,
188-
} {
189-
return self.reconcile(root, parent_scope, parent, slot, ex.deref_mut());
190-
}
178+
BNode::Tag(ex)
179+
if self.key == ex.key
180+
&& match (&self.inner, &ex.inner) {
181+
(VTagInner::Input(_), BTagInner::Input(_)) => true,
182+
(VTagInner::Textarea { .. }, BTagInner::Textarea { .. }) => true,
183+
(VTagInner::Other { tag: l, .. }, BTagInner::Other { tag: r, .. })
184+
if l == r =>
185+
{
186+
true
187+
}
188+
_ => false,
189+
} =>
190+
{
191+
return self.reconcile(root, parent_scope, parent, slot, ex.deref_mut());
191192
}
192193
_ => {}
193194
};

packages/yew/src/html/component/lifecycle.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,13 @@ where
192192
}
193193

194194
fn flush_messages(&mut self) -> bool {
195-
self.context
196-
.link()
197-
.pending_messages
198-
.drain()
199-
.into_iter()
200-
.fold(false, |acc, msg| {
201-
self.component.update(&self.context, msg) || acc
202-
})
195+
let mut changed = false;
196+
for msg in self.context.link().pending_messages.drain() {
197+
if self.component.update(&self.context, msg) {
198+
changed = true;
199+
}
200+
}
201+
changed
203202
}
204203

205204
#[cfg(feature = "csr")]

0 commit comments

Comments
 (0)