mirror of
https://github.com/martinvonz/jj.git
synced 2025-02-01 00:50:57 +00:00
cleanup: leverage BoxStream
/BoxFuture
type aliases
Thanks to @fowles for bringing these to my attention.
This commit is contained in:
parent
e2138ca2df
commit
8d67b1412e
2 changed files with 11 additions and 13 deletions
|
@ -71,7 +71,7 @@ pub struct CopyRecordOpts {
|
||||||
// TODO: Probably something for git similarity detection
|
// 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 {
|
pub trait Backend {
|
||||||
/// Get all copy records for `paths` in the dag range `roots..heads`.
|
/// Get all copy records for `paths` in the dag range `roots..heads`.
|
||||||
|
|
|
@ -22,8 +22,9 @@ use std::sync::Arc;
|
||||||
use std::task::{Context, Poll};
|
use std::task::{Context, Poll};
|
||||||
use std::{iter, vec};
|
use std::{iter, vec};
|
||||||
|
|
||||||
use futures::stream::StreamExt;
|
use futures::future::BoxFuture;
|
||||||
use futures::{Future, Stream, TryStreamExt};
|
use futures::stream::{BoxStream, StreamExt};
|
||||||
|
use futures::{Stream, TryStreamExt};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
|
||||||
use crate::backend;
|
use crate::backend;
|
||||||
|
@ -407,15 +408,12 @@ impl MergedTree {
|
||||||
/// Type alias for the result from `MergedTree::diff_stream()`. We use a
|
/// 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
|
/// `Stream` instead of an `Iterator` so high-latency backends (e.g. cloud-based
|
||||||
/// ones) can fetch trees asynchronously.
|
/// ones) can fetch trees asynchronously.
|
||||||
pub type TreeDiffStream<'matcher> = Pin<
|
pub type TreeDiffStream<'matcher> = BoxStream<
|
||||||
Box<
|
'matcher,
|
||||||
dyn Stream<
|
(
|
||||||
Item = (
|
RepoPathBuf,
|
||||||
RepoPathBuf,
|
BackendResult<(MergedTreeValue, MergedTreeValue)>,
|
||||||
BackendResult<(MergedTreeValue, MergedTreeValue)>,
|
),
|
||||||
),
|
|
||||||
> + 'matcher,
|
|
||||||
>,
|
|
||||||
>;
|
>;
|
||||||
|
|
||||||
fn all_tree_basenames(trees: &Merge<Tree>) -> impl Iterator<Item = &RepoPathComponent> {
|
fn all_tree_basenames(trees: &Merge<Tree>) -> impl Iterator<Item = &RepoPathComponent> {
|
||||||
|
@ -902,7 +900,7 @@ pub struct TreeDiffStreamImpl<'matcher> {
|
||||||
#[allow(clippy::type_complexity)]
|
#[allow(clippy::type_complexity)]
|
||||||
pending_trees: VecDeque<(
|
pending_trees: VecDeque<(
|
||||||
RepoPathBuf,
|
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
|
/// 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
|
/// accounting per path, so for there will often be twice as many pending
|
||||||
|
|
Loading…
Reference in a new issue