Skip to content

Commit

Permalink
Janitor: Fix clippy::len_without_is_empty
Browse files Browse the repository at this point in the history
  • Loading branch information
hunger authored and ogoffart committed Aug 4, 2021
1 parent ce4727b commit 60ef093
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sixtyfps_runtime/corelib/model.rs
Expand Up @@ -687,6 +687,11 @@ impl<C: RepeatedComponent> Repeater<C> {
self.inner.borrow().borrow().components.len()
}

/// Return true if the Repeater is empty
pub fn is_empty(&self) -> bool {
self.len() == 0
}

/// Returns a vector containing all components
pub fn components_vec(&self) -> Vec<ComponentRc<C>> {
self.inner.borrow().borrow().components.iter().flat_map(|x| x.1.clone()).collect()
Expand Down
5 changes: 5 additions & 0 deletions sixtyfps_runtime/corelib/sharedvector.rs
Expand Up @@ -138,6 +138,11 @@ impl<T> SharedVector<T> {
unsafe { self.inner.cast::<SharedVectorHeader>().as_ref().size }
}

/// Return true if the SharedVector is empty
pub fn is_empty(&self) -> bool {
self.len() == 0
}

/// Return a slice to the array
pub fn as_slice(&self) -> &[T] {
if self.len() == 0 {
Expand Down
5 changes: 5 additions & 0 deletions sixtyfps_runtime/corelib/string.rs
Expand Up @@ -41,6 +41,11 @@ impl SharedString {
self.inner.header.header
}

/// Return true if the String is empty
pub fn is_empty(&self) -> bool {
self.len() == 0
}

/// Return a slice to the string
pub fn as_str(&self) -> &str {
unsafe {
Expand Down

0 comments on commit 60ef093

Please sign in to comment.