Skip to content

Commit

Permalink
fix compile error in bytes feature
Browse files Browse the repository at this point in the history
  • Loading branch information
matsadler committed Sep 18, 2023
1 parent 5a4711b commit f3816f8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@

### Security

## [0.6.2] - 2023-09-18
### Fixed
- Compliation error in `bytes` feature.

## [0.6.1] - 2023-08-20
### Changed
- Support `rb-sys`' `stable-api` feature.
Expand Down Expand Up @@ -439,7 +443,8 @@
- Pre-built bindings for Ruby 2.6 - 3.1 on common platforms, build-time
generated bindings otherwise.

[Unreleased]: https://github.com/matsadler/magnus/compare/0.6.1...HEAD
[Unreleased]: https://github.com/matsadler/magnus/compare/0.6.2...HEAD
[0.6.2]: https://github.com/matsadler/magnus/compare/0.6.1...0.6.2
[0.6.1]: https://github.com/matsadler/magnus/compare/0.6.0...0.6.1
[0.5.5]: https://github.com/matsadler/magnus/compare/0.5.4...0.5.5
[0.6.0]: https://github.com/matsadler/magnus/compare/0.5.3...0.6.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ rb-sys = { version = "0.9.81", default-features = false, features = ["bindgen-rb
seq-macro = "0.3"

[dev-dependencies]
magnus = { path = ".", features = ["embed", "rb-sys"] }
magnus = { path = ".", features = ["embed", "rb-sys", "bytes"] }
rb-sys = { version = "0.9", default-features = false, features = ["stable-api-compiled-fallback"] }

[build-dependencies]
Expand Down
2 changes: 1 addition & 1 deletion src/r_string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1743,7 +1743,7 @@ unsafe impl IntoValueFromNative for &str {}
impl IntoValue for bytes::Bytes {
#[inline]
fn into_value_with(self, handle: &Ruby) -> Value {
handle.str_from_slice(self.as_ref()).into()
handle.str_from_slice(self.as_ref()).into_value_with(handle)
}
}

Expand Down
5 changes: 2 additions & 3 deletions tests/bytes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#[test]
#[cfg(feature = "bytes")]
fn it_converts_to_bytes() {
use magnus::{eval, RString};
use magnus::RString;

let ruby = unsafe { magnus::embed::init() };

let s: RString = unsafe { ruby.eval("[0,0,0].pack('c*')").unwrap() };
let s: RString = ruby.eval("[0,0,0].pack('c*')").unwrap();
assert_eq!(bytes::Bytes::from_static(&[0, 0, 0]), s.to_bytes());
}

0 comments on commit f3816f8

Please sign in to comment.