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

Bump magnus from 0.4.4 to 0.5.0 #230

Merged
merged 1 commit into from
Feb 13, 2023
Merged

Conversation

dependabot[bot]
Copy link
Contributor

@dependabot dependabot bot commented on behalf of github Feb 13, 2023

Bumps magnus from 0.4.4 to 0.5.0.

Release notes

Sourced from magnus's releases.

0.5.0

Magnus 0.5.0 adds many features, a handful of fixes, and some API changes.

Magnus is a Rust library providing a high-level easy to use interface to the C API of the Ruby programming language. Magnus lets you write Ruby extension libraries (or 'gems') in Rust, or embed Ruby in your Rust program.

Fixes

RStruct was missing an implementation of the ReprValue trait that would allow it to be passed to functions that require a value that is already a Ruby object. This trait implementation has now been added.

When converting Ruby values to RArray (or Vec<T>, [T; 1], or (T,)), an error will now be returned if given a non-Array (or non to_ary-able) value, rather than wrapping it in an array (see RArray::to_ary for the old behaviour).

Changes

There have been some internal changes to start making Magnus safe to use with multithreaded code. Many functions are now documented as panicking when called from a non-Ruby thread. This check is currently only performed in debug builds, as there is no api to avoid the performance hit of this check (calling these functions from a non-Ruby thread in a release build is undefined behaviour).

The IntoValue trait is now used instead of Into<Value> for converting to Ruby types. The Into<Value> implementations will be removed in the next release.

use magnus::prelude::* will now import traits anonymously.

New features

The bytes-crate feature can be enabled to allow automatic conversions between bytes::Bytes and Ruby strings.

typed_data::Obj<T>, is a Ruby object wrapping a Rust type known to be T. Previously you could declare a function accepting &T to receive a reference to the Rust data wrapped in a Ruby object, but you wouldn't have access to the wrapping object. Or if you declared the argument as Value you could get the wrapping object, but it was awkward to get the inner Rust data. typed_data::Obj<T> gets you the best of both worlds. See the typed_data_obj.rs test for an example.

TypedData::class_for can be implemented to customise the class on a case by case basis when wrapping Rust data in a Ruby object. See the docs for details. A simple interface to this is enabled with the #[wrap] macro now allowing #[magnus(class = "...")] attributes on enum variants.

The typed_data::Hash and typed_data::IsEql traits are automatically implemented for compatible types, providing Ruby compatible #hash and #eql? methods ready to be bound to your object.

error::Result<T> as a shorthand for std::result::Result<T, Error>.

The following Ruby API functions are now implemented in Magnus:

... (truncated)

Changelog

Sourced from magnus's changelog.

[0.5.0] - 2023-02-11

Added

  • typed_data::Obj<T>, a Ruby object wrapping a Rust type known to be T.
  • RArray::to_ary, RArray::assoc, RArray::rassoc, and RArray::cmp.
  • RHash::with_capacity new for Ruby 3.2.
  • RHash::bulk_insert.
  • Value::hash to generate a hash key for a Ruby object.
  • typed_data::Hash and typed_data::IsEql traits to help with implementing #hash and #eql? methods for wrapped structs.
  • Lots of RString methods: capacity, cmp, comparable, drop_bytes, dump, ellipsize, offset, plus, times, replace, scrub, shared_replace, split, update.
  • RRegexp::new/new_str, RRegexp::reg_match, and RRegexp::options.
  • The backref_get function to get the RMatch for the last regexp match.
  • RMatch::nth_defined, RMatch::nth_match, RMatch::backref_number, RMatch::matched, RMatch::pre, RMatch::post, and RMatch::last
  • RBignum::is_positive/is_negative.
  • new, num, and den for RRational, plus rationalize and rationalize_with_prec for Float.
  • RComplex::new, polar, real, imag, conjugate, abs & arg.
  • New Numeric trait implemented for Integer, Float, RRational, RComplex, etc. Exposes functions for applying operators to numeric types following Ruby's coercion protocol.
  • value::Id::new added to replace value::Id::from.
  • TypedData::class_for can be implemented to customise the class on a case by case basis when wrapping Rust data in a Ruby object.
  • The #[wrap] and #[derive(TypedData)] macros now allow setting #[magnus(class = "...")] on enum variants to customise the class per variant when wrapping enums in a Ruby object.
  • Value::funcall_public calls a public method, returning an error for a private or protected method.
  • error::Result<T> is shorthand for std::result::Result<T, Error>.
  • embed::setup to perform minimal initialisation of Ruby for environments where embed::init doesn't work.
  • The bytes-crate feature can be enabled to allow automatic conversions between bytes::Bytes and Ruby strings.

Changed

  • When converting Ruby values to RArray (or Vec<T>, [T; 1], or (T,)), an error will be returned if given a non-Array (or non-to_ary-able) value, rather than wrapping it in an array (see RArray::to_ary for the old behaviour).
  • r_typed_data::{DataType, DataTypeFunctions, DataTypeBuilder, TypedData} all moved to typed_data module, r_typed_data module removed. This should only affect DataTypeBuilder as it was the only one not exported at the crate root.
  • gc::adjust_memory_usage's argument changed to isize, rather than i32 or i64 depending on pointer width.
  • The IntoValue trait is now used instead of Into<Value> for converting to Ruby types.

... (truncated)

Commits

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [magnus](https://github.com/matsadler/magnus) from 0.4.4 to 0.5.0.
- [Release notes](https://github.com/matsadler/magnus/releases)
- [Changelog](https://github.com/matsadler/magnus/blob/main/CHANGELOG.md)
- [Commits](matsadler/magnus@0.4.4...0.5.0)

---
updated-dependencies:
- dependency-name: magnus
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot bot added dependencies Pull requests that update a dependency file rust Pull requests that update Rust code labels Feb 13, 2023
@github-actions github-actions bot merged commit b9fe07d into main Feb 13, 2023
@github-actions github-actions bot deleted the dependabot/cargo/magnus-0.5.0 branch February 13, 2023 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dependencies Pull requests that update a dependency file rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0 participants