Skip to content

Commit b539c3b

Browse files
authored
Add missing inline and From<Binary> for Term (#719)
1 parent a0c574d commit b539c3b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rustler/src/types/binary.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ impl<'a> Binary<'a> {
408408
/// If `offset + length` is out of bounds, this call results in *undefined behavior*. The
409409
/// caller has to ensure that `offset + length < self.len()`.
410410
#[allow(unused_unsafe)]
411+
#[inline]
411412
pub unsafe fn make_subbinary_unchecked(&self, offset: usize, length: usize) -> Binary<'a> {
412413
let raw_term = unsafe {
413414
enif_make_sub_binary(
@@ -438,7 +439,6 @@ impl Deref for Binary<'_> {
438439
self.as_slice()
439440
}
440441
}
441-
442442
impl<'a> Decoder<'a> for Binary<'a> {
443443
fn decode(term: Term<'a>) -> Result<Self, Error> {
444444
Binary::from_term(term)
@@ -473,6 +473,13 @@ impl<'a> Term<'a> {
473473
}
474474
}
475475

476+
impl<'a> From<Binary<'a>> for Term<'a> {
477+
#[inline]
478+
fn from(binary: Binary<'a>) -> Self {
479+
binary.term
480+
}
481+
}
482+
476483
/// An newly-created, mutable Erlang binary.
477484
///
478485
/// See [module-level doc](index.html) for more information.

0 commit comments

Comments
 (0)