MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / try_map

Method try_map

crates/data-structures/src/slim_slice.rs:931–935  ·  view source on GitHub ↗
(&self, by: impl FnMut(&T) -> Result<U, E>)

Source from the content-addressed store, hash-verified

929 /// Returns `Err(_)` if any call to `by` did.
930 #[inline]
931 pub fn try_map<U, E>(&self, by: impl FnMut(&T) -> Result<U, E>) -> Result<SlimSliceBox<U>, E> {
932 let mapped = self.iter().map(by).collect::<Result<_, _>>()?;
933 // SAFETY: Doing `.map(..)` can never change the length.
934 Ok(unsafe { SlimSliceBox::from_boxed_unchecked(mapped) })
935 }
936}
937
938impl<T: Debug> Debug for SlimSlice<'_, T> {

Callers

nothing calls this directly

Calls 3

iterMethod · 0.65
OkFunction · 0.50
mapMethod · 0.45

Tested by

no test coverage detected