Closed JosiahParry closed 4 months ago
This is a solid post.
@kbvernon @CGMossa let me know how we can get this into the new site.
thanks, josiah! i'm moving some content out of drafts. once i have that done. i'll puzzle over how to setup a blog here.
We need to create a blog section and can add this in there.
Instead, replace the
from_robj()
withtry_from()
.Removal of
#[extendr(use_try_from = true)]
Because
TryFrom
is the default now, the macro argumentuse_try_from = true
will cause a compiler error. For example thisbecomes
Setting
Attributes
Prior to version
0.7.0
theAttributes
trait did two undesirable things:Robj
The first was problematic because you lose the struct type when setting an attribute. The second was problematic because
Attributes::set_attrib()
method modified the underlyingSEXP
in place without requiring a mutable reference giving you an unsafe guarantee that the originalSEXP
would not be modified.For example migrating from to 0.7.0 in the package
{arcgisplaces}
results in the compiler error:A simplified version of the function looks like:
This function previously returned an
Robj
because that was the type returned byset_class()
. This function can be rewritten as.set_class()
returns a&mut Doubles
we can clone theDoubles
the result so that we have a non-mutable reference. Note that cloning only increases a reference counter and is not costly. Here.into_robj()
is used to return anRobj
Alternatively, the function can now return
Doubles
instead if you so desire:R-devel Non-API changes
R-devel is currently in the process of formalizing what is and is not part of the official C-API. As a result extendr powered R packages have WARN-ings due to non-API usage.
extendr 0.7.0 hides these behind a feature flag
non-api
. Unfortunately, due to the 1.69 minimum supported Rust version (MSRV) of CRAN combined with the lack of an MSRV in bindgen (which is used to generate R bindings), the non-api features cannot be provided automatically and require custom generation of R bindings vialibR-sys
.This will affect you if you are using the
global_var()
,local_var()
,base_env()
, variousEnvironment
,Function
,Primitive
, andPromise
methods.If you are affected by this, please create an issue and we can work through it together.