Skip to content

Commit

Permalink
cleanup: leverage BoxStream/BoxFuture type aliases
Browse files Browse the repository at this point in the history
Thanks to @fowles for bringing these to my attention.
  • Loading branch information
martinvonz committed Jun 26, 2024
1 parent e2138ca commit 8d67b14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/design/copy-tracking.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ pub struct CopyRecordOpts {
// TODO: Probably something for git similarity detection
}

pub type CopyRecordStream = Pin<Box<dyn Stream<Item = BackendResult<CopyRecord>>>>;
pub type CopyRecordStream = BoxStream<BackendResult<CopyRecord>>;

pub trait Backend {
/// Get all copy records for `paths` in the dag range `roots..heads`.
Expand Down
22 changes: 10 additions & 12 deletions lib/src/merged_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ use std::sync::Arc;
use std::task::{Context, Poll};
use std::{iter, vec};

use futures::stream::StreamExt;
use futures::{Future, Stream, TryStreamExt};
use futures::future::BoxFuture;
use futures::stream::{BoxStream, StreamExt};
use futures::{Stream, TryStreamExt};
use itertools::Itertools;

use crate::backend;
Expand Down Expand Up @@ -407,15 +408,12 @@ impl MergedTree {
/// Type alias for the result from `MergedTree::diff_stream()`. We use a
/// `Stream` instead of an `Iterator` so high-latency backends (e.g. cloud-based
/// ones) can fetch trees asynchronously.
pub type TreeDiffStream<'matcher> = Pin<
Box<
dyn Stream<
Item = (
RepoPathBuf,
BackendResult<(MergedTreeValue, MergedTreeValue)>,
),
> + 'matcher,
>,
pub type TreeDiffStream<'matcher> = BoxStream<
'matcher,
(
RepoPathBuf,
BackendResult<(MergedTreeValue, MergedTreeValue)>,
),
>;

fn all_tree_basenames(trees: &Merge<Tree>) -> impl Iterator<Item = &RepoPathComponent> {
Expand Down Expand Up @@ -902,7 +900,7 @@ pub struct TreeDiffStreamImpl<'matcher> {
#[allow(clippy::type_complexity)]
pending_trees: VecDeque<(
RepoPathBuf,
Pin<Box<dyn Future<Output = BackendResult<(MergedTree, MergedTree)>> + 'matcher>>,
BoxFuture<'matcher, BackendResult<(MergedTree, MergedTree)>>,
)>,
/// The maximum number of trees to request concurrently. However, we do the
/// accounting per path, so for there will often be twice as many pending
Expand Down

0 comments on commit 8d67b14

Please sign in to comment.