Skip to content

Commit

Permalink
extendr-api: Implement R-internal by trait requirements,
Browse files Browse the repository at this point in the history
not only for `Robj`.
  • Loading branch information
CGMossa committed Apr 6, 2024
1 parent c23c6c6 commit c14539b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion extendr-api/src/io/load.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,4 @@ pub trait Load {
}
}

impl Load for Robj {}
impl<T: ?Sized> Load for T {}
2 changes: 1 addition & 1 deletion extendr-api/src/io/save.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ pub trait Save: GetSexp {
}
}

impl<R: GetSexp> Save for R {}
impl<T: ?Sized + GetSexp> Save for T {}
2 changes: 1 addition & 1 deletion extendr-api/src/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ pub trait AsStrIter: GetSexp + Types + Length + Attributes + Rinternals {
}
}

impl AsStrIter for Robj {}
impl<T: ?Sized + GetSexp + Types + Length + Attributes> AsStrIter for T {}

impl TryFrom<&Robj> for StrIter {
type Error = Error;
Expand Down
4 changes: 3 additions & 1 deletion extendr-api/src/robj/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ pub trait Eval: GetSexp {
}
}

impl Eval for Robj {}
impl<T: ?Sized + GetSexp> Eval for T {}

/// Generic access to typed slices in an Robj.
pub trait AsTypedSlice<'a, T>
Expand All @@ -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]>;
}

Expand Down

0 comments on commit c14539b

Please sign in to comment.