Skip to content

Convert a Rust struct to a Python tuple #2825

Discussion options

You must be logged in to vote

At the moment we don't have a #[derive] for the into-Python direction (we might have one eventually), however at the moment this is easy enough by just returning a Rust tuple of the fields:

#[pyfunction]
fn point_to_tuple(point: Point) -> (isize, isize) {
    (point.x, point.y)
}

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by JackAshwell11
Comment options

You must be logged in to vote
2 replies
@davidhewitt
Comment options

@JackAshwell11
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants