From b6970d0e260aa33bb1e22ae7df739470ecad19e0 Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Thu, 6 Apr 2023 17:03:42 +0000 Subject: [PATCH] Use `FnOnce` for `slice_owned` instead of `Fn` --- compiler/rustc_codegen_ssa/src/back/metadata.rs | 2 +- compiler/rustc_data_structures/src/owned_slice.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/rustc_codegen_ssa/src/back/metadata.rs b/compiler/rustc_codegen_ssa/src/back/metadata.rs index c0f263d1478..3e3fcc08bd6 100644 --- a/compiler/rustc_codegen_ssa/src/back/metadata.rs +++ b/compiler/rustc_codegen_ssa/src/back/metadata.rs @@ -37,7 +37,7 @@ pub struct DefaultMetadataLoader; fn load_metadata_with( path: &Path, - f: impl for<'a> Fn(&'a [u8]) -> Result<&'a [u8], String>, + f: impl for<'a> FnOnce(&'a [u8]) -> Result<&'a [u8], String>, ) -> Result { let file = File::open(path).map_err(|e| format!("failed to open file '{}': {}", path.display(), e))?; diff --git a/compiler/rustc_data_structures/src/owned_slice.rs b/compiler/rustc_data_structures/src/owned_slice.rs index 146f06a1c69..e35a93f2a1d 100644 --- a/compiler/rustc_data_structures/src/owned_slice.rs +++ b/compiler/rustc_data_structures/src/owned_slice.rs @@ -59,7 +59,7 @@ pub struct OwnedSlice { pub fn slice_owned(owner: O, slicer: F) -> OwnedSlice where O: Send + Sync + 'static, - F: Fn(&O) -> &[u8], + F: FnOnce(&O) -> &[u8], { try_slice_owned(owner, |x| Ok::<_, !>(slicer(x))).into_ok() } @@ -70,7 +70,7 @@ where pub fn try_slice_owned(owner: O, slicer: F) -> Result where O: Send + Sync + 'static, - F: Fn(&O) -> Result<&[u8], E>, + F: FnOnce(&O) -> Result<&[u8], E>, { // We box the owner of the bytes, so it doesn't move. //