From 45ceb42624d641e9bd701d2d77c96ae586b14e9b Mon Sep 17 00:00:00 2001 From: Mossa Date: Sun, 24 Mar 2024 19:55:51 +0100 Subject: [PATCH] extendr-api: Implement R-internal by trait requirements, not only for `Robj`. --- extendr-api/src/io/load.rs | 2 +- extendr-api/src/io/save.rs | 2 +- extendr-api/src/iter.rs | 2 +- extendr-api/src/robj/mod.rs | 4 +++- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/extendr-api/src/io/load.rs b/extendr-api/src/io/load.rs index e655febe32..f010ef7871 100644 --- a/extendr-api/src/io/load.rs +++ b/extendr-api/src/io/load.rs @@ -74,4 +74,4 @@ pub trait Load { } } -impl Load for Robj {} +impl Load for T {} diff --git a/extendr-api/src/io/save.rs b/extendr-api/src/io/save.rs index a892685d8b..d66449941f 100644 --- a/extendr-api/src/io/save.rs +++ b/extendr-api/src/io/save.rs @@ -106,4 +106,4 @@ pub trait Save: GetSexp { } } -impl Save for R {} +impl Save for T {} diff --git a/extendr-api/src/iter.rs b/extendr-api/src/iter.rs index 6d32e32990..0fa324c18a 100644 --- a/extendr-api/src/iter.rs +++ b/extendr-api/src/iter.rs @@ -201,7 +201,7 @@ pub trait AsStrIter: GetSexp + Types + Length + Attributes + Rinternals { } } -impl AsStrIter for Robj {} +impl AsStrIter for T {} impl TryFrom<&Robj> for StrIter { type Error = Error; diff --git a/extendr-api/src/robj/mod.rs b/extendr-api/src/robj/mod.rs index b536c24ab0..d8a8f92b3d 100644 --- a/extendr-api/src/robj/mod.rs +++ b/extendr-api/src/robj/mod.rs @@ -760,7 +760,7 @@ pub trait Eval: GetSexp { } } -impl Eval for Robj {} +impl Eval for T {} /// Generic access to typed slices in an Robj. pub trait AsTypedSlice<'a, T> @@ -770,7 +770,9 @@ where fn try_into_typed_slice(&self) -> Result<&'a [T]>; fn try_into_typed_slice_mut(&mut self) -> Result<&'a mut [T]>; + #[deprecated] fn as_typed_slice(&self) -> Option<&'a [T]>; + #[deprecated] fn as_typed_slice_mut(&mut self) -> Option<&'a mut [T]>; }