Expand description
Borrowed external arguments (#2106): &T / &mut T for a TypedExternal
type, the views ExternalPtrRef<'_, T> / ExternalPtrMut<'_, T>, and an
Option of either.
The wrapper converts the argument to its ExternalPtr<T> handle with the
other arguments (from_r::__mx_external_arg, which unwraps and roots a
class handle), then borrows the value’s RefCell the way a method receiver
is borrowed: shared for &T and ExternalPtrRef, exclusive for &mut T
and ExternalPtrMut. The borrow is taken after every conversion and held
through return conversion, and the body gets the plain reference (or the
view). One object passed twice with a &mut T, or a callback into R that
reaches the object while the function runs, then raises the
miniextendr_borrow_conflict error instead of making a second reference.
An ExternalPtr<T> parameter is a handle the body keeps or consumes: it
takes no borrow, and reads through it are borrow() / borrow_mut().
A borrowed argument keeps the call on R’s main thread
(crate::type_inspect::is_main_thread_bound_input), like a &self
receiver.
Structs§
- External
Arg 🔒 - A borrowed external argument’s type, taken apart.
Enums§
- Mode 🔒
- How a borrowed external argument holds its value.
Constants§
- NOT_
EXTERNAL 🔒 - Names that are never an external value behind
&/&mut: R’s native borrows,&str/&Path, the dots, the RNG guard anrngwrapper passes (#2002), and containers with conversions of their own.
Functions§
- arg_
borrows 🔒 - The borrows of the borrowed external parameters of
inputs, except thoseunborrowednames (a parameter marker rebinds them to another type). Each binds the parameter to its reference or view, holding the value’sRefCelluntil the wrapper’s closure ends, after return conversion. - external_
arg 🔒 - The borrowed external argument
tydescribes, if any:&T/&mut TwhereTnames a type with no R-side conversion of its own (no type check, not inNOT_EXTERNAL), or anExternalPtrRef<'_, T>/ExternalPtrMut<'_, T>view, either one optionally underOption. Matched on the written type: a&TwhoseTisn’tTypedExternalis a compile error at the type (ExternalPtr<T>requires it). - handle_
conversion 🔒 - The statement converting the borrowed argument
ident(of typearg) to its handle, given its R-facing failure arm (err_arm, anErr(e) =>match arm).self_tyreplacesSelf. - handle_
ident 🔒 - The binding of the handle a borrowed argument
paramconverts to. Mixed-site: user parameters may use any spelling. - is_
external_ 🔒value - replace_
self 🔒 tywithSelfreplaced byself_ty(an impl method’s wrapper is a free function, whereSelfnames nothing).