summaryrefslogtreecommitdiff
path: root/rust/src/rc.rs
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-01-05 17:29:14 -0500
committerKyleMiles <krm504@nyu.edu>2023-01-06 16:29:58 -0500
commita154e45cce79b0c2264c1e1cd37a3d1bf5bc6154 (patch)
tree11f436b720edfdf37819e9e83e7131d220687074 /rust/src/rc.rs
parent52edc39a7081fd6662e14fbcd473adabbbc36c7a (diff)
Rust API: Lots and lots of clippy changes
Diffstat (limited to 'rust/src/rc.rs')
-rw-r--r--rust/src/rc.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/rust/src/rc.rs b/rust/src/rc.rs
index 1c7de9da..57deddc3 100644
--- a/rust/src/rc.rs
+++ b/rust/src/rc.rs
@@ -147,6 +147,7 @@ impl<'a, T> Guard<'a, T>
where
T: RefCountable,
{
+ #[allow(clippy::should_implement_trait)] // This _is_ out own (lite) version of that trait
pub fn clone(&self) -> Ref<T> {
unsafe { <T as RefCountable>::inc_ref(&self.contents) }
}
@@ -230,6 +231,11 @@ impl<P: CoreOwnedArrayProvider> Array<P> {
self.count
}
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ self.count == 0
+ }
+
pub fn into_raw_parts(self) -> (*mut P::Raw, usize) {
let me = mem::ManuallyDrop::new(self);
(me.contents, me.count)
@@ -302,6 +308,11 @@ impl<P: CoreArrayProvider> ArrayGuard<P> {
pub fn len(&self) -> usize {
self.count
}
+
+ #[inline]
+ pub fn is_empty(&self) -> bool {
+ self.count == 0
+ }
}
impl<'a, P: 'a + CoreArrayWrapper<'a> + CoreArrayProvider> ArrayGuard<P> {
@@ -355,7 +366,7 @@ where
fn next(&mut self) -> Option<P::Wrapped> {
self.it
.next()
- .map(|r| unsafe { P::wrap_raw(r, &self.context) })
+ .map(|r| unsafe { P::wrap_raw(r, self.context) })
}
#[inline]
@@ -382,7 +393,7 @@ where
fn next_back(&mut self) -> Option<P::Wrapped> {
self.it
.next_back()
- .map(|r| unsafe { P::wrap_raw(r, &self.context) })
+ .map(|r| unsafe { P::wrap_raw(r, self.context) })
}
}