Skip to content

Commit

Permalink
fix: lints
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Sep 18, 2024
1 parent 8cfba9f commit d85664b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
run: cargo fmt --check -- --config "unstable_features=true,imports_granularity=Crate,group_imports=StdExternalCrate"

- name: Clippy no-default-features
run: cargo clippy --no-default-features --all-targets -- --deny warnings
run: cargo +stable clippy --no-default-features --all-targets -- --deny warnings

- name: Clippy
run: cargo clippy --all-features --all-targets -- --deny warnings
run: cargo +stable clippy --all-features --all-targets -- --deny warnings

build:
needs: check
Expand Down
30 changes: 1 addition & 29 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,42 +93,14 @@ pub(crate) fn generic(cls: &Bound<PyType>, args: &Bound<PyAny>) -> PyObject {
.unbind()
}

pub(crate) struct TryProcessIter<'a, I, E> {
iter: I,
error: &'a mut Option<E>,
}

impl<I: Iterator<Item = Result<T, E>>, T, E> Iterator for TryProcessIter<'_, I, E> {
type Item = T;

fn next(&mut self) -> Option<Self::Item> {
match self.iter.next() {
Some(Ok(x)) => Some(x),
Some(Err(err)) => {
*self.error = Some(err);
None
}
None => None,
}
}

fn size_hint(&self) -> (usize, Option<usize>) {
if self.error.is_some() {
(0, Some(0))
} else {
self.iter.size_hint()
}
}
}

pub(crate) fn short_type_name<T: ?Sized>() -> &'static str {
let name = std::any::type_name::<T>();
name.rsplit_once("::").map_or(name, |(_, name)| name)
}

pub(crate) fn wait<T: Send>(
py: Python,
resolve: impl zenoh::Resolve<zenoh::Result<T>> + Send,
resolve: impl zenoh::Resolve<zenoh::Result<T>>,
) -> PyResult<T> {
py.allow_threads(|| resolve.wait()).into_pyres()
}

0 comments on commit d85664b

Please sign in to comment.