Skip to content

Commit

Permalink
use Borrow instead of AuthToken refs in export method
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Dec 15, 2024
1 parent f2855df commit eec03c3
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/stock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
// or implied. See the License for the specific language governing permissions and limitations under
// the License.

use alloc::collections::BTreeSet;
use alloc::collections::{BTreeMap, BTreeSet};
use core::borrow::Borrow;
use core::iter;
use std::collections::BTreeMap;
// Used in strict encoding; once solved there, remove here
use std::io;
use std::io::ErrorKind;
Expand Down Expand Up @@ -117,24 +117,24 @@ impl<S: Supply<CAPS>, const CAPS: u32> Stock<S, CAPS> {
Ok(())
}

pub fn export<'a>(
pub fn export(
&mut self,
terminals: impl IntoIterator<Item = &'a AuthToken>,
terminals: impl IntoIterator<Item = impl Borrow<AuthToken>>,
writer: StrictWriter<impl WriteRaw>,
) -> io::Result<()> {
self.export_aux(terminals, writer, |_| iter::empty::<()>())
}

// TODO: Return statistics
pub fn export_aux<'a, Aux: StrictEncode, I: ExactSizeIterator<Item = Aux>>(
pub fn export_aux<Aux: StrictEncode, I: ExactSizeIterator<Item = Aux>>(
&mut self,
terminals: impl IntoIterator<Item = &'a AuthToken>,
terminals: impl IntoIterator<Item = impl Borrow<AuthToken>>,
mut writer: StrictWriter<impl WriteRaw>,
aux: impl Fn(Opid) -> I,
) -> io::Result<()> {
let queue = terminals
.into_iter()
.map(|terminal| self.state.addr(*terminal).opid)
.map(|terminal| self.state.addr(*terminal.borrow()).opid)
.collect::<BTreeSet<_>>();
let mut opids = queue.clone();
let mut queue = queue.into_iter();
Expand Down Expand Up @@ -492,9 +492,9 @@ pub mod fs {
self.export_all(writer)
}

pub fn export_to_file<'a>(
pub fn export_to_file(
&mut self,
terminals: impl IntoIterator<Item = &'a AuthToken>,
terminals: impl IntoIterator<Item = impl Borrow<AuthToken>>,
output: impl AsRef<Path>,
) -> io::Result<()> {
let file = File::create_new(output)?;
Expand Down

0 comments on commit eec03c3

Please sign in to comment.