2021-09-14 12:07:23 +00:00
|
|
|
use pyo3::FromPyObject;
|
2020-08-30 10:54:13 +00:00
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct Foo();
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct Foo2 {}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EmptyEnum {}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithEmptyTupleVar {
|
|
|
|
EmptyTuple(),
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithEmptyStructVar {
|
|
|
|
EmptyStruct {},
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
struct EmptyTransparentTup();
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
struct EmptyTransparentStruct {}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithTransparentEmptyTupleVar {
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
EmptyTuple(),
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithTransparentEmptyStructVar {
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
EmptyStruct {},
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
struct TransparentTupTooManyFields(String, String);
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
struct TransparentStructTooManyFields {
|
|
|
|
foo: String,
|
|
|
|
bar: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithTransparentTupleTooMany {
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
EmptyTuple(String, String),
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum EnumWithTransparentStructTooMany {
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
EmptyStruct {
|
|
|
|
foo: String,
|
|
|
|
bar: String,
|
|
|
|
},
|
|
|
|
Valid(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct UnknownAttribute {
|
|
|
|
#[pyo3(attr)]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct InvalidAttributeArg {
|
|
|
|
#[pyo3(attribute(1))]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct TooManyAttributeArgs {
|
|
|
|
#[pyo3(attribute("a", "b"))]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct EmptyAttributeArg {
|
|
|
|
#[pyo3(attribute(""))]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct NoAttributeArg {
|
|
|
|
#[pyo3(attribute())]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct TooManyitemArgs {
|
|
|
|
#[pyo3(item("a", "b"))]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct NoItemArg {
|
|
|
|
#[pyo3(item())]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct ItemAndAttribute {
|
|
|
|
#[pyo3(item, attribute)]
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(unknown = "should not work")]
|
|
|
|
struct UnknownContainerAttr {
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(annotation = "should not work")]
|
|
|
|
struct AnnotationOnStruct {
|
|
|
|
a: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum InvalidAnnotatedEnum {
|
|
|
|
#[pyo3(annotation = 1)]
|
|
|
|
Foo(String),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum TooManyLifetimes<'a, 'b> {
|
|
|
|
Foo(&'a str),
|
|
|
|
Bar(&'b str),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
union Union {
|
|
|
|
a: usize,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
enum UnitEnum {
|
|
|
|
Unit,
|
|
|
|
}
|
|
|
|
|
2021-02-20 15:15:20 +00:00
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct InvalidFromPyWith {
|
|
|
|
#[pyo3(from_py_with)]
|
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct InvalidFromPyWithLiteral {
|
|
|
|
#[pyo3(from_py_with = func)]
|
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
2022-06-08 05:41:31 +00:00
|
|
|
#[derive(FromPyObject)]
|
|
|
|
struct InvalidTupleGetter(#[pyo3(item("foo"))] String);
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(transparent)]
|
|
|
|
struct InvalidTransparentWithGetter {
|
|
|
|
#[pyo3(item("foo"))]
|
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
2023-04-26 04:48:12 +00:00
|
|
|
#[derive(FromPyObject)]
|
2023-04-26 11:47:07 +00:00
|
|
|
#[pyo3(from_item_all)]
|
2023-04-27 04:44:38 +00:00
|
|
|
struct FromItemAllOnTuple(String);
|
2023-04-26 04:48:12 +00:00
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
2023-04-26 11:47:07 +00:00
|
|
|
#[pyo3(from_item_all)]
|
2023-04-26 04:48:12 +00:00
|
|
|
#[pyo3(transparent)]
|
2023-04-27 04:44:38 +00:00
|
|
|
struct FromItemAllWithTransparent {
|
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
|
|
|
#[pyo3(from_item_all, from_item_all)]
|
|
|
|
struct MultipleFromItemAll {
|
2023-04-26 04:48:12 +00:00
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
2023-04-26 11:47:07 +00:00
|
|
|
#[pyo3(from_item_all)]
|
2023-04-26 04:48:12 +00:00
|
|
|
struct UselessItemAttr {
|
|
|
|
#[pyo3(item)]
|
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
2023-04-26 11:47:07 +00:00
|
|
|
#[pyo3(from_item_all)]
|
2023-04-27 04:44:38 +00:00
|
|
|
struct FromItemAllConflictAttr {
|
|
|
|
#[pyo3(attribute)]
|
2023-04-26 04:48:12 +00:00
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(FromPyObject)]
|
2023-04-26 11:47:07 +00:00
|
|
|
#[pyo3(from_item_all)]
|
2023-04-27 04:44:38 +00:00
|
|
|
struct FromItemAllConflictAttrWithArgs {
|
|
|
|
#[pyo3(attribute("f"))]
|
2023-04-26 04:48:12 +00:00
|
|
|
field: String,
|
|
|
|
}
|
|
|
|
|
2020-08-30 10:54:13 +00:00
|
|
|
fn main() {}
|