Comments (2)
So Ruby's C API has a bunch of functions to check a value is of a certain type (or convert it to that type with the implicit conversion methods, to_str
, to_ary
, etc).
There's some like rb_check_<type>_type
that return the value if it's of that type, call to_<typ>
if it responds to that method, or return nil
if it can't be converted. Magnus looks for that nil
and raises an error.
Then there's rb_str_to_str
which returns the value if it's a string, calls to_str
if the object responds to it, or errors if it can't be converted. This is convenient as then the code in Magnus doesn't have to do the extra nil
check to return an error in the last case.
The array conversions are done using rb_ary_to_ary
. Turns out this does not work like rb_str_to_str
. Instead of erroring if the value can't be converted (or returning nil
) it returns the value wrapped in an array.
In my defence, at the time I wrote this code the Ruby C API was totally undocumented (the headers now do document this potential confusion).
I've fixed this in 69ff299, but as it's a change in behaviour I'm going to put of releasing till 0.5.
from magnus.
In my defence, at the time I wrote this code the Ruby C API was totally undocumented (the headers now do document this potential confusion).
No worries at all! Thank you for the project, Iām just calling what I see. š Thanks for the quick fix!
from magnus.
Related Issues (20)
- Add Support for Passing an Array to Proc.Call HOT 1
- Discussion: Pin Ruby values to the stack HOT 5
- Feature Request: Add default type parameters to scan_args
- Sidekiq not handling signals? HOT 7
- `Vec<Vec<(String, usize)>>` panics with unsatisfied trait bounds HOT 3
- `AsRef`
- Deadlock when first creating rust-ext objects on threads HOT 5
- Integration with Rust futures?
- Question: Best approach to implementing a timestamp with nanosecond precision and timezone awareness HOT 3
- Question about a performance issue HOT 6
- Confused about how to pass a Ruby array to a Rust function HOT 1
- How well does the embed feature work? HOT 1
- Build is broken when trying to use Bytes feature HOT 2
- a possible solution for unlocking the GVL
- Instructions for Examples HOT 3
- MSRV Change HOT 1
- RHash.lookup for bool value HOT 5
- Automatic `frozen?` check HOT 2
- Exposing mutable wrapped class methods HOT 1
- Magnus overhead compared to rb-sys HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from magnus.