Skip to content

Commit

Permalink
clippy fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
alecmocatta committed Apr 5, 2021
1 parent 90ce3ab commit bc57c1e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
"us-east-1.data-analytics",
"cflogworkshop/optimized/cf-accesslogs/",
AwsCredentials::Anonymous,
)))
)), None)
.await?;
// Note: this isn't yet implemented!
Expand Down Expand Up @@ -222,7 +222,7 @@ fn main() -> Result<(), Box<dyn Error>> {
"us-east-1.data-analytics",
"cflogworkshop/optimized/cf-accesslogs/",
AwsCredentials::Anonymous,
)))
)), None)
.await?;

let top_pages = rows
Expand Down
3 changes: 2 additions & 1 deletion amadeus-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
clippy::needless_pass_by_value,
clippy::unnecessary_wraps,
clippy::missing_panics_doc,
clippy::let_underscore_drop
clippy::let_underscore_drop,
clippy::unnested_or_patterns
)]
#![deny(unsafe_code)]

Expand Down
2 changes: 1 addition & 1 deletion amadeus-core/src/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ impl<S: ?Sized + Sink<Item> + Unpin, St: ?Sized + Stream<Item = Item> + Unpin, I
let items = &mut **self_.items;
let mut given_all = false;
let stream = stream::poll_fn(|cx| match Pin::new(&mut *items).poll_next(cx) {
x @ (Poll::Ready(Some(_)) | Poll::Pending) => x,
x @ Poll::Ready(Some(_)) | x @ Poll::Pending => x,
Poll::Ready(None) => {
given_all = true;
Poll::Pending
Expand Down
28 changes: 14 additions & 14 deletions amadeus-streaming/src/top.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,61 +281,61 @@ mod test {

#[derive(Serialize, Deserialize)]
#[serde(bound = "")]
struct HLL<V>(HyperLogLog<V>);
impl<V: Hash> Ord for HLL<V> {
struct Hll<V>(HyperLogLog<V>);
impl<V: Hash> Ord for Hll<V> {
#[inline(always)]
fn cmp(&self, other: &Self) -> cmp::Ordering {
self.0.len().partial_cmp(&other.0.len()).unwrap()
}
}
impl<V: Hash> PartialOrd for HLL<V> {
impl<V: Hash> PartialOrd for Hll<V> {
#[inline(always)]
fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> {
self.0.len().partial_cmp(&other.0.len())
}
}
impl<V: Hash> PartialEq for HLL<V> {
impl<V: Hash> PartialEq for Hll<V> {
#[inline(always)]
fn eq(&self, other: &Self) -> bool {
self.0.len().eq(&other.0.len())
}
}
impl<V: Hash> Eq for HLL<V> {}
impl<V: Hash> Clone for HLL<V> {
impl<V: Hash> Eq for Hll<V> {}
impl<V: Hash> Clone for Hll<V> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<V: Hash> New for HLL<V> {
impl<V: Hash> New for Hll<V> {
type Config = f64;
fn new(config: &Self::Config) -> Self {
Self(New::new(config))
}
}
impl<V: Hash> Intersect for HLL<V> {
impl<V: Hash> Intersect for Hll<V> {
fn intersect<'a>(iter: impl Iterator<Item = &'a Self>) -> Option<Self>
where
Self: Sized + 'a,
{
Intersect::intersect(iter.map(|x| &x.0)).map(Self)
}
}
impl<'a, V: Hash> UnionAssign<&'a HLL<V>> for HLL<V> {
impl<'a, V: Hash> UnionAssign<&'a Hll<V>> for Hll<V> {
fn union_assign(&mut self, rhs: &'a Self) {
self.0.union_assign(&rhs.0)
}
}
impl<'a, V: Hash> ops::AddAssign<&'a V> for HLL<V> {
impl<'a, V: Hash> ops::AddAssign<&'a V> for Hll<V> {
fn add_assign(&mut self, rhs: &'a V) {
self.0.add_assign(rhs)
}
}
impl<V: Hash> Debug for HLL<V> {
impl<V: Hash> Debug for Hll<V> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
self.0.fmt(fmt)
}
}
impl<V> IntersectPlusUnionIsPlus for HLL<V> {
impl<V> IntersectPlusUnionIsPlus for Hll<V> {
const VAL: bool = <HyperLogLog<V> as IntersectPlusUnionIsPlus>::VAL;
}

Expand All @@ -344,7 +344,7 @@ mod test {
fn top_hll() {
let mut rng =
rand::rngs::SmallRng::from_seed([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
let mut top = Top::<String, HLL<String>>::new(1000, 0.99, 2.0 / 1000.0, 0.00408);
let mut top = Top::<String, Hll<String>>::new(1000, 0.99, 2.0 / 1000.0, 0.00408);
// let mut x = HashMap::new();
for _ in 0..5_000 {
let (a, b) = (rng.gen_range(0, 2) == 0, rng.gen_range(0, 2) == 0);
Expand Down Expand Up @@ -373,7 +373,7 @@ mod test {

let mut rng =
rand::rngs::SmallRng::from_seed([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]);
let mut top = Top::<String, HLL<String>>::new(1000, 0.99, 2.0 / 1000.0, 0.05);
let mut top = Top::<String, Hll<String>>::new(1000, 0.99, 2.0 / 1000.0, 0.05);
// let mut x = HashMap::new();
for _ in 0..5_000_000 {
let (a, b) = (rng.gen_range(0, 2) == 0, rng.gen_range(0, 2) == 0);
Expand Down
2 changes: 1 addition & 1 deletion src/pool/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl ThreadPool {
wasm_bindgen_futures::spawn_local(remote);
Guard::new(remote_handle.map_ok(|t| {
let t: *mut dyn Send = Box::into_raw(t);
*Box::from_raw(t as *mut T)
*Box::from_raw(t.cast::<T>())
}))
}
}
Expand Down

0 comments on commit bc57c1e

Please sign in to comment.