mirror of
https://github.com/ankitects/anki.git
synced 2025-09-20 15:02:21 -04:00
Use fat pointer to avoid propogating generics
This commit is contained in:
parent
ed24fd13db
commit
e65b79ba63
6 changed files with 10 additions and 10 deletions
|
@ -65,7 +65,7 @@ impl Collection {
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> Context<'_, F> {
|
||||
impl Context<'_> {
|
||||
pub(super) fn import_cards_and_revlog(
|
||||
&mut self,
|
||||
imported_notes: &HashMap<NoteId, NoteId>,
|
||||
|
|
|
@ -26,7 +26,7 @@ impl<'d> DeckContext<'d> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> Context<'_, F> {
|
||||
impl Context<'_> {
|
||||
pub(super) fn import_decks_and_configs(&mut self) -> Result<HashMap<DeckId, DeckId>> {
|
||||
let mut ctx = DeckContext::new(self.target_col, self.usn);
|
||||
ctx.import_deck_configs(mem::take(&mut self.data.deck_configs))?;
|
||||
|
|
|
@ -32,7 +32,7 @@ pub(super) struct MediaUseMap {
|
|||
unchecked: Vec<SafeMediaEntry>,
|
||||
}
|
||||
|
||||
impl<F: FnMut(ImportProgress) -> Result<()>> Context<'_, F> {
|
||||
impl Context<'_> {
|
||||
pub(super) fn prepare_media(&mut self) -> Result<MediaUseMap> {
|
||||
let progress_fn = |u| (&mut self.progress_fn)(ImportProgress::MediaCheck(u)).is_ok();
|
||||
let existing_sha1s = self.target_col.all_existing_sha1s(progress_fn)?;
|
||||
|
|
|
@ -20,19 +20,19 @@ use crate::{
|
|||
search::SearchNode,
|
||||
};
|
||||
|
||||
struct Context<'a, F> {
|
||||
struct Context<'a> {
|
||||
target_col: &'a mut Collection,
|
||||
archive: ZipArchive<File>,
|
||||
data: ExchangeData,
|
||||
usn: Usn,
|
||||
progress_fn: F,
|
||||
progress_fn: &'a mut dyn Fn(ImportProgress) -> Result<()>,
|
||||
}
|
||||
|
||||
impl Collection {
|
||||
pub fn import_apkg(
|
||||
&mut self,
|
||||
path: impl AsRef<Path>,
|
||||
progress_fn: impl FnMut(ImportProgress) -> Result<()>,
|
||||
progress_fn: &mut dyn Fn(ImportProgress) -> Result<()>,
|
||||
) -> Result<OpOutput<()>> {
|
||||
let file = File::open(path)?;
|
||||
let archive = ZipArchive::new(file)?;
|
||||
|
@ -44,11 +44,11 @@ impl Collection {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, F: FnMut(ImportProgress) -> Result<()>> Context<'a, F> {
|
||||
impl<'a> Context<'a> {
|
||||
fn new(
|
||||
mut archive: ZipArchive<File>,
|
||||
target_col: &'a mut Collection,
|
||||
progress_fn: F,
|
||||
progress_fn: &'a mut dyn Fn(ImportProgress) -> Result<()>,
|
||||
) -> Result<Self> {
|
||||
let data =
|
||||
ExchangeData::gather_from_archive(&mut archive, SearchNode::WholeCollection, true)?;
|
||||
|
|
|
@ -43,7 +43,7 @@ impl NoteMeta {
|
|||
}
|
||||
}
|
||||
|
||||
impl<F> Context<'_, F> {
|
||||
impl Context<'_> {
|
||||
pub(super) fn import_notes_and_notetypes(
|
||||
&mut self,
|
||||
media_map: &mut MediaUseMap,
|
||||
|
|
|
@ -39,7 +39,7 @@ fn roundtrip() {
|
|||
|_| (),
|
||||
)
|
||||
.unwrap();
|
||||
target_col.import_apkg(&apkg_path, |_| Ok(())).unwrap();
|
||||
target_col.import_apkg(&apkg_path, &mut |_| Ok(())).unwrap();
|
||||
|
||||
target_col.assert_decks();
|
||||
target_col.assert_notetype(¬etype);
|
||||
|
|
Loading…
Reference in a new issue