phlow 3.0.0

An engine for scripting reactive browsers in Rust by adding custom views to structures
Documentation
#[derive(Debug, PartialEq, Eq)]
struct CloneOnly(&'static str);

impl Clone for CloneOnly {
    fn clone(&self) -> Self {
        Self(self.0)
    }
}

#[derive(Debug, PartialEq, Eq)]
struct Plain;

#[derive(Debug, PartialEq, Eq, Copy, Clone)]
struct CopyAndClone(u8);

#[test]
fn try_to_clone_returns_the_same_value_for_copy_types() {
    assert_eq!(phlow::try_to_clone!(CopyAndClone(7)), Some(CopyAndClone(7)));

    let value = CopyAndClone(9);
    assert_eq!(phlow::try_to_clone!(&value), Some(CopyAndClone(9)));
}

#[test]
fn try_to_clone_uses_clone_for_borrowed_and_owned_values() {
    let value = CloneOnly("hello");

    assert_eq!(
        phlow::try_to_clone!(value.clone()),
        Some(CloneOnly("hello"))
    );
    assert_eq!(phlow::try_to_clone!(&value), Some(CloneOnly("hello")));
}

#[test]
fn try_to_clone_returns_none_for_plain_types_in_both_forms() {
    assert_eq!(phlow::try_to_clone!(Plain), None);
    assert_eq!(phlow::try_to_clone!(&Plain), None);
}