Skip to content

Commit

Permalink
Merge pull request #453 from thoth-pub/feature/rustc_1.65.0_linting
Browse files Browse the repository at this point in the history
Fix new Clippy lints (unwrap_or_else for defaults, explicit auto-deref) under rustc 1.65.0
  • Loading branch information
rhigman committed Nov 3, 2022
2 parents 35e2da1 + 4c4d8eb commit cde1755
Show file tree
Hide file tree
Showing 17 changed files with 82 additions and 107 deletions.
4 changes: 2 additions & 2 deletions thoth-app/src/component/affiliations_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ impl Component for AffiliationsFormComponent {
/>
<FormTextInput
label="Position"
value={ self.affiliation.position.clone().unwrap_or_else(|| "".to_string()) }
value={ self.affiliation.position.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangePosition(e.to_value())) }
/>
<FormNumberInput
Expand Down Expand Up @@ -612,7 +612,7 @@ impl AffiliationsFormComponent {
html! {
<tr class="row">
<td>{&a.institution.institution_name}</td>
<td>{&a.position.clone().unwrap_or_else(|| "".to_string())}</td>
<td>{&a.position.clone().unwrap_or_default()}</td>
<td>{&a.affiliation_ordinal.clone()}</td>
<td>
<a
Expand Down
4 changes: 2 additions & 2 deletions thoth-app/src/component/contributions_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ impl Component for ContributionsFormComponent {
/>
<FormTextInput
label="Biography"
value={ self.contribution.biography.clone().unwrap_or_else(|| "".to_string()) }
value={ self.contribution.biography.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeBiography(e.to_value())) }
/>
<FormBooleanSelect
Expand Down Expand Up @@ -684,7 +684,7 @@ impl ContributionsFormComponent {
<div class="field" style="width: 8em;">
<label class="label">{ "Biography" }</label>
<div class="control is-expanded">
{&c.biography.clone().unwrap_or_else(|| "".to_string())}
{&c.biography.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
Expand Down
20 changes: 10 additions & 10 deletions thoth-app/src/component/fundings_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,27 +353,27 @@ impl Component for FundingsFormComponent {
</div>
<FormTextInput
label="Program"
value={ self.new_funding.program.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_funding.program.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeProgram(e.to_value())) }
/>
<FormTextInput
label="Project Name"
value={ self.new_funding.project_name.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_funding.project_name.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeProjectName(e.to_value())) }
/>
<FormTextInput
label="Project Short Name"
value={ self.new_funding.project_shortname.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_funding.project_shortname.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeProjectShortname(e.to_value())) }
/>
<FormTextInput
label="Grant Number"
value={ self.new_funding.grant_number.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_funding.grant_number.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeGrant(e.to_value())) }
/>
<FormTextInput
label="Jurisdiction"
value={ self.new_funding.jurisdiction.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_funding.jurisdiction.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeJurisdiction(e.to_value())) }
/>

Expand Down Expand Up @@ -444,31 +444,31 @@ impl FundingsFormComponent {
<div class="field" style="width: 8em;">
<label class="label">{ "Program" }</label>
<div class="control is-expanded">
{&f.program.clone().unwrap_or_else(|| "".to_string())}
{&f.program.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
<label class="label">{ "Project Name" }</label>
<div class="control is-expanded">
{&f.project_name.clone().unwrap_or_else(|| "".to_string())}
{&f.project_name.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
<label class="label">{ "Project Short Name" }</label>
<div class="control is-expanded">
{&f.project_shortname.clone().unwrap_or_else(|| "".to_string())}
{&f.project_shortname.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
<label class="label">{ "Grant Number" }</label>
<div class="control is-expanded">
{&f.grant_number.clone().unwrap_or_else(|| "".to_string())}
{&f.grant_number.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
<label class="label">{ "Jurisdiction" }</label>
<div class="control is-expanded">
{&f.jurisdiction.clone().unwrap_or_else(|| "".to_string())}
{&f.jurisdiction.clone().unwrap_or_default()}
</div>
</div>
<div class="field">
Expand Down
6 changes: 3 additions & 3 deletions thoth-app/src/component/locations_form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl Component for LocationsFormComponent {
/>
<FormUrlInput
label="Full Text URL"
value={ self.new_location.full_text_url.clone().unwrap_or_else(|| "".to_string()) }
value={ self.new_location.full_text_url.clone().unwrap_or_default() }
oninput={ ctx.link().callback(|e: InputEvent| Msg::ChangeFullTextUrl(e.to_value())) }
/>
<FormLocationPlatformSelect
Expand Down Expand Up @@ -381,13 +381,13 @@ impl LocationsFormComponent {
<div class="field" style="width: 8em;">
<label class="label">{ "Landing Page" }</label>
<div class="control is-expanded">
{&l.landing_page.clone().unwrap_or_else(|| "".to_string())}
{&l.landing_page.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
<label class="label">{ "Full Text URL" }</label>
<div class="control is-expanded">
{&l.full_text_url.clone().unwrap_or_else(|| "".to_string())}
{&l.full_text_url.clone().unwrap_or_default()}
</div>
</div>
<div class="field" style="width: 8em;">
Expand Down
2 changes: 1 addition & 1 deletion thoth-app/src/component/new_work.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ impl Component for NewWorkComponent {
<div class="tile is-child">
<figure class="image is-fullwidth">
<img
src={self.work.cover_url.clone().unwrap_or_else(|| "".to_string()).clone()}
src={self.work.cover_url.clone().unwrap_or_default().clone()}
loading="lazy"
/>
</figure>
Expand Down
18 changes: 9 additions & 9 deletions thoth-app/src/component/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ impl Component for PublicationComponent {
<div class="field">
<label class="label">{ "ISBN" }</label>
<div class="control is-expanded">
{&self.publication.isbn.as_ref().map(|s| s.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.isbn.as_ref().map(|s| s.to_string()).unwrap_or_default()}
</div>
</div>
</form>
Expand All @@ -343,28 +343,28 @@ impl Component for PublicationComponent {
<div class="field" style="width: 8em;">
<label class="label">{ "Width (mm)" }</label>
<div class="control is-expanded">
{&self.publication.width_mm.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.width_mm.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Height (mm)" }</label>
<div class="control is-expanded">
{&self.publication.height_mm.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.height_mm.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Depth (mm)" }</label>
<div class="control is-expanded">
{&self.publication.depth_mm.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.depth_mm.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Weight (g)" }</label>
<div class="control is-expanded">
{&self.publication.weight_g.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.weight_g.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>
</div>
Expand All @@ -373,28 +373,28 @@ impl Component for PublicationComponent {
<div class="field" style="width: 8em;">
<label class="label">{ "Width (in)" }</label>
<div class="control is-expanded">
{&self.publication.width_in.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.width_in.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Height (in)" }</label>
<div class="control is-expanded">
{&self.publication.height_in.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.height_in.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Depth (in)" }</label>
<div class="control is-expanded">
{&self.publication.depth_in.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.depth_in.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>

<div class="field" style="width: 8em;">
<label class="label">{ "Weight (oz)" }</label>
<div class="control is-expanded">
{&self.publication.weight_oz.as_ref().map(|w| w.to_string()).unwrap_or_else(|| "".to_string())}
{&self.publication.weight_oz.as_ref().map(|w| w.to_string()).unwrap_or_default()}
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit cde1755

Please sign in to comment.