Skip to content

Commit

Permalink
unwrap_or_default
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhly committed Oct 16, 2023
1 parent b47bea9 commit 54fdc00
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/conversions/hashbrown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ where
Err(msg) => {
if let Ok(mappingproxy) = ob.downcast::<PyMappingProxy>() {
let mut ret = hashbrown::HashMap::with_capacity_and_hasher(
mappingproxy.len(),
mappingproxy.len().unwrap_or_default(),
S::default(),
);
for (k, v) in mappingproxy {
Expand Down
2 changes: 1 addition & 1 deletion src/conversions/indexmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ where
Err(msg) => {
if let Ok(mappingproxy) = ob.downcast::<PyMappingProxy>() {
let mut ret = indexmap::IndexMap::with_capacity_and_hasher(
mappingproxy.len(),
mappingproxy.len().unwrap_or_default(),
S::default(),
);
for (k, v) in mappingproxy {
Expand Down
2 changes: 1 addition & 1 deletion src/conversions/std/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
Err(msg) => {
if let Ok(mappingproxy) = ob.downcast::<PyMappingProxy>() {
let mut ret = collections::HashMap::with_capacity_and_hasher(
mappingproxy.len()?,
mappingproxy.len().unwrap_or_default(),
S::default(),
);
for (k, v) in mappingproxy {
Expand Down
2 changes: 1 addition & 1 deletion src/types/mappingproxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ impl PyMappingProxy {

/// Checks if the mappingproxy is empty, i.e. `len(self) == 0`.
pub fn is_empty(&self) -> bool {
self.len().unwrap() == 0
self.len().unwrap_or_default() == 0
}

/// Gets an item from the mappingproxy.
Expand Down

0 comments on commit 54fdc00

Please sign in to comment.