Skip to content

Commit

Permalink
Merge 2518fd5 into 6d197e2
Browse files Browse the repository at this point in the history
  • Loading branch information
Licenser authored Aug 27, 2024
2 parents 6d197e2 + 2518fd5 commit b359578
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/value/tape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,24 @@ impl<'input> Tape<'input> {
// so we can safely change the lifetime of the tape to 'new
unsafe { std::mem::transmute(self) }
}

/// Deserializes the tape into a type that implements `serde::Deserialize`
/// # Errors
/// Returns an error if the deserialization fails
#[cfg(feature = "serde")]
pub fn deserialize<T>(self) -> crate::Result<T>
where
T: serde::Deserialize<'input>,
{
use crate::Deserializer;

let mut deserializer = Deserializer {
tape: self.0,
idx: 0,
};

T::deserialize(&mut deserializer)
}
}

/// Wrapper around the tape that allows interaction via a `Value`-like API.
Expand Down

0 comments on commit b359578

Please sign in to comment.