MCPcopy Index your code
hub / github.com/RustPython/RustPython / map

Method map

crates/common/src/borrow.rs:37–52  ·  view source on GitHub ↗
(s: Self, f: F)

Source from the content-addressed store, hash-verified

35
36impl<'a, T: ?Sized> BorrowedValue<'a, T> {
37 pub fn map<U: ?Sized, F>(s: Self, f: F) -> BorrowedValue<'a, U>
38 where
39 F: FnOnce(&T) -> &U,
40 {
41 match s {
42 Self::Ref(r) => BorrowedValue::Ref(f(r)),
43 Self::MuLock(m) => BorrowedValue::MappedMuLock(PyMutexGuard::map_immutable(m, f)),
44 Self::MappedMuLock(m) => {
45 BorrowedValue::MappedMuLock(PyImmutableMappedMutexGuard::map(m, f))
46 }
47 Self::ReadLock(r) => BorrowedValue::MappedReadLock(PyRwLockReadGuard::map(r, f)),
48 Self::MappedReadLock(m) => {
49 BorrowedValue::MappedReadLock(PyMappedRwLockReadGuard::map(m, f))
50 }
51 }
52 }
53}
54
55impl<T: ?Sized> Deref for BorrowedValue<'_, T> {

Callers 15

try_from_objectMethod · 0.45
get_propMethod · 0.45
callMethod · 0.45
call_methodMethod · 0.45
constructMethod · 0.45
newMethod · 0.45
valueMethod · 0.45
thenMethod · 0.45
exec_pyFunction · 0.45
idsMethod · 0.45
py_to_jsFunction · 0.45
object_entriesFunction · 0.45

Calls 1

fFunction · 0.50

Tested by 3

write_inputFunction · 0.36
fromMethod · 0.36