Skip to content

Commit

Permalink
bug: removed &[u32] interpretation of Robj (extendr#767)
Browse files Browse the repository at this point in the history
* fix: remove wrong `u32` casting

* fix: removed invalid `u32` conversion

* CHANGELOG: made a breaking change section,
added description of PR

* fix changelog

* CHANGELOG: quick fix
  • Loading branch information
CGMossa authored May 30, 2024
1 parent 9d548d3 commit 6ea456a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 12 deletions.
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
place, and then return an untyped owned pointer (Robj). Instead, now we return `&mut Self`.
- [_Potentially breaking_]: `RArray::from_parts` no longer requires a pointer to the underlying data
vector [[#657]](https://github.com/extendr/extendr/pull/657)
- [**Breaking change**]: In `AltRep` the `unserialize_ex`, `set_parent`, `set_envflags` are
- `#[extendr(use_try_from = true)` is now the default setting, therefore the option has `use_try_from` has been removed [[#759]](https://github.com/extendr/extendr/pull/759)

#### Breaking changes

- In `AltRep` the `unserialize_ex`, `set_parent`, `set_envflags` are
now hidden behind the feature flag `non-api`. Also, `Promise::from_parts` is marked as non-API.
- [**Breaking change**]: Floating point numbers with decimal part can no longer be converted to integer types via
- Floating point numbers with decimal part can no longer be converted to integer types via
rounding [[#757]](https://github.com/extendr/extendr/pull/757)
- [**Breaking change**]: You can no longer create an `Robj` from a reference `&T`, where `T` is an `extendr`-impl. [[#759]](https://github.com/extendr/extendr/pull/759)
- [**Breaking change**]: You can no longer use `from_robj`, as the trait `FromRobj` as been removed. Instead, use `try_from`.
- `#[extendr(use_try_from = true)` is now the default setting, therefore the option has `use_try_from` has been removed [[#759]](https://github.com/extendr/extendr/pull/759)
- You can no longer create an `Robj` from a reference `&T`, where `T` is an `extendr`-impl. [[#759]](https://github.com/extendr/extendr/pull/759)
- You can no longer use `from_robj`, as the trait `FromRobj` as been removed. Instead, use `try_from`.
- It is no longer possible to access an R integer vector as a `&[u32]` [[#767]](https://github.com/extendr/extendr/pull/767)

### Fixed

- returning `&Self` or `&mut Self` from a method in an `#[extendr]`-impl would
result in unintended cloning [[[#614](https://github.com/extendr/extendr/issues/614)]]
result in unintended cloning [[#614]](https://github.com/extendr/extendr/issues/614)
- `TryFrom<&Robj>` and `FromRobj` for integer scalars now correctly handles conversions
from `f64` [[#757]](https://github.com/extendr/extendr/pull/757)

Expand Down
2 changes: 0 additions & 2 deletions extendr-api/src/optional/ndarray.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ macro_rules! make_array_view_2 {
make_array_view_1!(Rbool, Error::ExpectedLogical);
make_array_view_1!(Rint, Error::ExpectedInteger);
make_array_view_1!(i32, Error::ExpectedInteger);
make_array_view_1!(u32, Error::ExpectedInteger);
make_array_view_1!(Rfloat, Error::ExpectedReal);
make_array_view_1!(f64, Error::ExpectedReal);
make_array_view_1!(Rcplx, Error::ExpectedComplex);
Expand All @@ -127,7 +126,6 @@ make_array_view_1!(Rstr, Error::ExpectedString);
make_array_view_2!(Rbool, "Not a logical matrix.", Error::ExpectedLogical);
make_array_view_2!(Rint, "Not an integer matrix.", Error::ExpectedInteger);
make_array_view_2!(i32, "Not an integer matrix.", Error::ExpectedInteger);
make_array_view_2!(u32, "Not an integer matrix.", Error::ExpectedInteger);
make_array_view_2!(Rfloat, "Not a floating point matrix.", Error::ExpectedReal);
make_array_view_2!(f64, "Not a floating point matrix.", Error::ExpectedReal);
make_array_view_2!(
Expand Down
1 change: 0 additions & 1 deletion extendr-api/src/robj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ macro_rules! make_typed_slice {

make_typed_slice!(Rbool, INTEGER, LGLSXP);
make_typed_slice!(i32, INTEGER, INTSXP);
make_typed_slice!(u32, INTEGER, INTSXP);
make_typed_slice!(Rint, INTEGER, INTSXP);
make_typed_slice!(f64, REAL, REALSXP);
make_typed_slice!(Rfloat, REAL, REALSXP);
Expand Down
3 changes: 0 additions & 3 deletions extendr-api/tests/ndarray_try_from_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ mod ndarray_try_from_tests {
assert_eq!(mapped, expected);
}

let view = <ArrayView2<u32>>::try_from(&robj)?;
assert_eq!(view.dim(), (4, 2));

for (&mapped, expected) in view.iter().zip(1..=8) {
assert_eq!(mapped, expected);
}
Expand Down

0 comments on commit 6ea456a

Please sign in to comment.