chiark / gitweb /
bundles: Try to slightly reduce amount of Zip monomorphisation
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 11 May 2021 23:46:44 +0000 (00:46 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 11 May 2021 23:46:44 +0000 (00:46 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/bundles.rs

index efdbecc28f73fecefee6e5d1e77d57fa7b2ad1e3..d54dfc5a309684786882ab4548b371944016239a 100644 (file)
@@ -254,6 +254,9 @@ impl MgmtBundleList {
 
 //---------- loading ----------
 
+trait ReadSeek: Read + io::Seek { }
+impl<T> ReadSeek for T where T: Read + io::Seek { }
+
 impl From<ZipError> for LoadError {
   fn from(ze: ZipError) -> LoadError {
     match ze {
@@ -404,9 +407,8 @@ impl BundleParseErrorHandling for BundleParseUpload {
 }
 
 #[throws(EH::Err)]
-fn parse_bundle<EH,F>(id: Id, file: &mut F, eh: EH) -> Parsed
-where EH: BundleParseErrorHandling,
-      F: Read + io::Seek
+fn parse_bundle<EH>(id: Id, file: &mut dyn ReadSeek, eh: EH) -> Parsed
+  where EH: BundleParseErrorHandling,
 {
   match id.kind { Kind::Zip => () }
   let mut za = eh.required(||{