Enable clippy::unnecessary_unwrap (#8756)

This PR enables the
[`clippy::unnecessary_unwrap`](https://rust-lang.github.io/rust-clippy/master/index.html#/unnecessary_unwrap)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 23:10:56 -05:00 committed by GitHub
parent 191fcf67d1
commit 373e18bc88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 15 deletions

View File

@ -19,11 +19,9 @@ pub struct Embedding(pub Vec<f32>);
impl FromSql for Embedding {
fn column_result(value: ValueRef) -> FromSqlResult<Self> {
let bytes = value.as_blob()?;
let embedding: Result<Vec<f32>, Box<bincode::ErrorKind>> = bincode::deserialize(bytes);
if embedding.is_err() {
return Err(rusqlite::types::FromSqlError::Other(embedding.unwrap_err()));
}
Ok(Embedding(embedding.unwrap()))
let embedding =
bincode::deserialize(bytes).map_err(|err| rusqlite::types::FromSqlError::Other(err))?;
Ok(Embedding(embedding))
}
}

View File

@ -51,8 +51,10 @@ impl<M: ManagedView> PopoverMenu<M> {
cx.subscribe(&new_menu, move |modal, _: &DismissEvent, cx| {
if modal.focus_handle(cx).contains_focused(cx) {
if previous_focus_handle.is_some() {
cx.focus(previous_focus_handle.as_ref().unwrap())
if let Some(previous_focus_handle) =
previous_focus_handle.as_ref()
{
cx.focus(previous_focus_handle);
}
}
*menu2.borrow_mut() = None;

View File

@ -154,8 +154,8 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
cx.subscribe(&new_menu, move |modal, _: &DismissEvent, cx| {
if modal.focus_handle(cx).contains_focused(cx) {
if previous_focus_handle.is_some() {
cx.focus(previous_focus_handle.as_ref().unwrap())
if let Some(previous_focus_handle) = previous_focus_handle.as_ref() {
cx.focus(previous_focus_handle);
}
}
*menu2.borrow_mut() = None;
@ -165,11 +165,12 @@ impl<M: ManagedView> Element for RightClickMenu<M> {
cx.focus_view(&new_menu);
*menu.borrow_mut() = Some(new_menu);
*position.borrow_mut() = if attach.is_some() && child_layout_id.is_some() {
attach.unwrap().corner(child_bounds)
} else {
cx.mouse_position()
};
*position.borrow_mut() =
if let Some(attach) = attach.filter(|_| child_layout_id.is_some()) {
attach.corner(child_bounds)
} else {
cx.mouse_position()
};
cx.refresh();
}
});

View File

@ -112,7 +112,6 @@ fn run_clippy(args: ClippyArgs) -> Result<()> {
"clippy::suspicious_to_owned",
"clippy::type_complexity",
"clippy::unnecessary_to_owned",
"clippy::unnecessary_unwrap",
"clippy::useless_conversion",
"clippy::useless_format",
"clippy::vec_init_then_push",