Changelog
Unreleased
Added
Changed
Fixed
Deprecated
0.7.0
Added
- Arguments can be (mutable) typed slices such as
&[Rbool],&mut [Rint]etc. [#790] - New optional
faerfeature which enables conversion betweenfaermatrix andRMatrix<f64>[#706] - Adds
TryFrom<Robj>and<TryFrom<&Robj>forimplblocks marked with#[extendr]macro allowing falliable conversion to&Self&mut Self[#730] - Adds
From<T> for Robjfor impl blocks marked with#[extendr]macro - The new
ExpectedExternalNonNullPtrerror variant provides a more informative error when a null pointer is accessed RArray::data_mutprovides a mutable slice to the underlying array data [#657]- Implements the
Attributestrait for all R vector wrapper structs (e.g.Integers,Doubles,Strings, etc.), allowing for easy access and setting of the attributes of an R object [#745]. This comes with breaking changes. See below. - feature
non-apithat gives access to non-API items; Requires compile-time generation of bindings [#754] TryFrom<&Robj>forStrIter,HashMap<K, Robj>forK = StringandK = &str[#759]
Changed
- [Potentially breaking]:
RArray::from_partsno longer requires a pointer to the underlying data vector [#657] #[extendr(use_try_from = true)is now the default setting, therefore the optionuse_try_fromhas been removed [#759]
Breaking changes
- R-devel Non-API changes:
- R’s C API is being formalized. While the changes are formalized, non-API functions are hidden behind a feature flag to prevent removal from CRAN.
- Non-API changes are in flux in R-devel, however, CRAN has set a July 9th date to remove any package that uses non-API functions. This includes almost every extendr based package on CRAN.
- See [Rd] clarifying and adjusting the C API for R
- nonAPI.txt functions are hidden behind the
non-apifeature flag. - Removed from default include (but may not be limited to):
global_var(),local_var(),base_env(), variousEnvironment,Function,Primitive, andPromisemethods.
Attributestrait now returns a mutable reference toSelf. [#745]. Previously.set_attrib()would modify an object in place, and then return an untyped owned pointer (Robj). Instead, now we return&mut Self.- In
AltReptheunserialize_ex,set_parent,set_envflagsare now hidden behind the feature flagnon-api. Also,Promise::from_partsis marked as non-API. - Floating point numbers with decimal part can no longer be converted to integer types via rounding [#757]
- You can no longer create an
Robjfrom a reference&T, whereTis anextendr-impl. [#759] - You can no longer use
from_robj, as the traitFromRobjas been removed. Instead, usetry_from. - It is no longer possible to access an R integer vector as a
&[u32][#767] - It is no longer possible to generate bindings as part of the compilation of extendr. Feature
non-apiis broken and will not compile. Related https://github.com/extendr/libR-sys/issues/251
Fixed
0.6.0
Added
ALTLISTsupport allowing users to represent structs as R list objects [#600]- [either]
TryFrom<&Robj> for Either<T, R>andFrom<Either<T, R>> for RobjifTandRare themselves implement these traits. This unblocks scenarios like accepting any numeric vector from R viaEither<Integers, Doubles>without extra memory allocation [#480] PartialOrdtrait implementation forRfloat,RintandRbool.RfloatandRintgainedmin()andmax()methods [#573]use_rngoption for theextendrattribute macro, which enables the use of random number sampling methods from R, e.g.#[extendr(use_rng = true)[#476][T; N]conversions toRobj[#594]ToVectorValueforRfloat,RintandRbool[#593]TryFrom<_>onVec<_>forIntegers(i32),Complexes(c64),Doubles(f64), andLogicals(bool/i32). [#593]Rstrcan now be constructed fromOption<String>[#630]
Fixed
- You can now create
ArrayView1from&Robjas well asRobj[#501] - Raw literals from Rust can be used for function and argument names. e.g.
fn r#type()in Rust is converted totype()in R. [#531] - Fix memory leaks on errors and panics [#555]
- Fixed error when collecting too many objects into
List, etc. [#540]
0.4.0
Added
- Support for setting the default value of arguments to struct methods, using
#[default = "..."][#436] - [ndarray]
TryFrom<&Robj>forArrayView1<T>andArrayView2<T>, whereTisi32,f64,c64,Rint,Rfloat,Rcplx,Rstr,Rbool[#443] Debugtrait implementation forRcplxandComplexes[#444]TryFrom<Robj>,From<Option<T>>,Into<Option<T>>and their variations forNullable<T>[#446]Nullable<T>::map()that acts on not null value and propagatesNULL[#446]- [ndarray] Conversion from owned arrays (ie
ndarray::Array) intoRobj[#450] - [ndarray][docs] Documentation for the
robj_ndarraymodule [#450] Sumfor scalars likeRint,RfloatandRcplx, which acceptIterator<Item = &Rtype>[#454]- A new
collect_rarraymethod that can be used to collect arbitrary iterables into an R matrix [#466] - [docs] Documentation for
RArray::new_matrix()[#466]
Changed
- [docs] Use bindgen on docs.rs, to ensure newer R features will still be documented [#426]
- Unify the tagging mechanism used to identify Rust types inside
ExternalPtr. This allows#[extendr]-annotated functions to directly acceptExternalPtr<MyStruct>as well asMyStruct[#433] Nullable<T>is now part ofextendr_api::prelude[#446]- Bump the Rust edition from 2018 to 2021 [#458]
- When converted to
STRSXP, strings are now correctly marked as UTF-8 even on non-UTF-8 platforms (i.e., R < 4.2 on Windows), which shouldn’t matter for most of the users [#467]
Fixed
- The R CMD check note “Found non-API calls to R” by moving
use extendr_engine;insidetest!macro [#424] - The clippy lint “this public function might dereference a raw pointer but is not marked
unsafe” [#451] - A bug where importing a submodule via
use some_module;inside theextendr_module!macro wasn’t working [#469]
0.3.0
Added
Functiontype that wraps an R function, which can be invoked using thecall()method. [#188]pairlist!macro for generatingPairlistobjects, e.g. for use in function calls. [#202]use_try_fromoption for theextendrmacro, which allows the use of any type that implementsTryInto<Robj>/TryFrom<Robj>, e.g.#[extendr(use_try_from = true)]. [#222]Support for R version 4.2. [#235]
call!macro, which can be used to call an R function whose name is provided as a string. [#238]Large Rust integer types (
u32,u64andi64) can now be converted to R’snumerictype, which can handle large integer values. [#242]TryFrom<Robj>for a large number of Rust types. [#249], [#258]S4struct, which wraps an S4 class in R. [#268][ndarray] Implemented
TryFrom<&ArrayBase> for Robj, allowingextendr-annotated functions to return Arrays from thendarraycrate and have them automatically converted to R arrays. [#275]Rint,Rdouble,RboolandRcplx:NA-aware wrappers for scalar elements of R vectors [#274], [#284], [#301], [#338], [#350]Integers,Doubles,Strings,LogicalsandComplexes: wrappers for R vectors that deref to slices of the above types (RIntetc). [#274], [#284], [#301], [#338], [#350]ExternalPtr, a wrapper class for creating R objects containing any Rust object. [#260][graphics] Support for R graphics and graphics devices. The
graphicsfeature flag is disabled by default. [#279], [#360], [#373], [#379], [#380], [#389]Derefimplementation for vector types (Rint/Rfloat/Rbool/Rstr/Robj) to appropriately typed Rust slices. [#327]defaultoption forextendr-annotated functions, allowing them to have default values, e.g.fn fred(#[default="NULL"] x: Option<i32>) { }. [#334]r_nameoption forextendr-annotated functions, allowing the generated R function to have a different name. e.g.#[extendr( use_try_from = true, r_name = "test.rename.rlike", mod_name = "test_rename_mymod" )] fn test_rename() { }Ranytype and theas_anyconversion method. [#320]std::fmt::Debugimplementation for wrapper types. [#345]#[derive(TryFromRobj)and#[derive(IntoRobj)]which provide an automatic conversion from and to any custom Rust struct andRobj[#347][[operator that works with Rust classes. Its behavior is identical to that of the$operator. [#359]LoadandSave, traits that, once implemented, provide the ability to load and save R data in the RDS format. These traits are implemented for allRobj. [#363]Dataframewrapper struct. [#393]IntoDataFrametrait, which can be derived to allow arbitrary Rust structs to be converted to rows of a data frame. [#393]
Changed
Strings::eltnow returns anRstr. [#345]Renamed
RTypetoRtype. [#345]Wrapper types now contain
Robjfields. [#190]The
R!macro now accepts strings that contain R code. This is now the recommended way of using the macro, especially with raw strings e.g.R!(r#" print("hello") "#);Improved error handling for
<&str>::try_from(Robj). [#226]SymPair::sym_pair()now returns(Option<Robj>, Robj). [#225]More detailed error messages when converting Rust integer types to R. [#243]
Characteris now calledRstr. [#273][ndarray] Bumped
ndarrayto 0.15.3. Under RFC 1977 this is a “public dependency” change, and therefore can be considered a breaking change, as consumers ofextendrthat use an older version ofndarraywill no longer be compatible until they also bumpndarrayto a compatible version. [#275]IsNAtrait has been renamed toCanBeNA. [#288]list!has been rewritten, and now returns aListstruct. [#303]
Deprecated
- Calling the
R!macro with non-string types (e.g.R!(1)) is now deprecated. [#203]
Removed
extendr 0.2.0
Added contributing guidelines and code of conduct.
Made use of ndarray optional.
Made #[extendr] calls panic and thread safe.
Added NA handling to the #[extendr] macro.
Added a separate extendr-engine crate that is needed when calling R from Rust.
Wrapper classes for pairlists, environment, raw, symbols and others.
More iterator support.
Operators index, slice, dollar, double_colon, +, -, * and /`.
Debug printing support expanded to use wrappers.
Conversion of Robj to wrapper types.
Multithreaded support - allows multithreaded testing using a recursive spinlock.
Bool type extended and implemented using TRUE, FALSE and NA_BOOLEAN.
Optional parameters to support NA handing.
Errors thrown if input parameters without Option are NA.
Harmonising of function names into integer, real, logical, symbol, raw, list, pairlist and env.
Refactored robj code into several source files.
Many functions updated to use generic types.
R! macro for executing R source code.
call! macro to call R code.
sym! macro to generate symbols.
Simplification of vector generation using collect_robj and ToVectorValue.
Added array types
[1, 2, 3]asRobj::fromtargets.Macros now mostly return errors.
extendr 0.1.10
- Fix build on Windows and MacOS.