#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct EventPayload<T> {
value: T,
}
impl<T> EventPayload<T> {
pub fn new(value: T) -> Self {
Self { value }
}
pub const fn get(&self) -> &T {
&self.value
}
pub fn into_inner(self) -> T {
self.value
}
}
impl<T> From<T> for EventPayload<T> {
fn from(value: T) -> Self {
Self::new(value)
}
}
#[cfg(test)]
mod tests {
use super::EventPayload;
#[test]
fn wraps_payload_values() {
let payload = EventPayload::new("rustuse build");
assert_eq!(*payload.get(), "rustuse build");
assert_eq!(payload.into_inner(), "rustuse build");
}
#[test]
fn converts_from_inner_value() {
let payload = EventPayload::from(7_u8);
assert_eq!(*payload.get(), 7);
}
}