Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Deref implementations for wrappers. #327

Merged
merged 3 commits into from
Dec 7, 2021
Merged

Conversation

andy-thomason
Copy link
Contributor

This PR adds derefs for wrapper types.

Vectors deref to slices of their value (Rint /Rfloat/Rbool/Rstr/Robj).

Some Vectors deref to mutable slices (Rint/Rfloat/Rbool) but not Rstr and Robj which need set_elt to work.

ExternalPtr derefs to &T so we can use it like Box.

Rstr derefs to &str

We could deref Robj to &Rany - answers on a postcard.

@andy-thomason
Copy link
Contributor Author

andy-thomason commented Nov 23, 2021

This will enable us to do:

fn fred(x: Integers) -> Rint {
   x[2]
}

fn fred(x: List) -> Robj {
   x[2].clone()
}

@yutannihilation
Copy link
Contributor

Looks very useful!

@andy-thomason andy-thomason linked an issue Nov 24, 2021 that may be closed by this pull request
@andy-thomason andy-thomason merged commit 92bc46f into master Dec 7, 2021
@andy-thomason andy-thomason deleted the derefs-for-wrappers branch December 7, 2021 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Change how Deref works with Wrappers.
2 participants