Created
April 12, 2023 15:55
-
-
Save Haaroon/1fbf00919d55ba339344cf8048ec000c to your computer and use it in GitHub Desktop.
GRAVEYARD FOR MY DIRECTION FILE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use docbrown::core::Direction; | |
use pyo3::{pyclass, PyRef, PyRefMut}; | |
use pyo3::{PyObject, Python}; | |
use std::fmt; | |
#[pyclass(name = "Direction")] | |
#[derive(Clone)] | |
pub enum PyDirection { | |
BOTH, | |
IN, | |
OUT, | |
} | |
impl fmt::Display for PyDirection { | |
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | |
match self { | |
PyDirection::BOTH => write!(f, "BOTH"), | |
PyDirection::IN => write!(f, "IN"), | |
PyDirection::OUT => write!(f, "OUT"), | |
} | |
} | |
} | |
impl From<PyDirection> for Direction { | |
fn from(direction: PyDirection) -> Direction { | |
// implement match for different values of str for in both and out | |
match direction { | |
PyDirection::BOTH => Direction::BOTH, | |
PyDirection::IN => Direction::IN, | |
PyDirection::OUT => Direction::OUT, | |
} | |
} | |
} | |
impl From<Direction> for PyDirection { | |
fn from(direction: Direction) -> PyDirection { | |
match direction { | |
Direction::BOTH => PyDirection::BOTH, | |
Direction::IN => PyDirection::IN, | |
Direction::OUT => PyDirection::OUT, | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment