You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

functional.rs 766 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. use pyo3::pyclass;
  2. use python_special_method_derive::DirHelper;
  3. #[pyclass]
  4. #[derive(DirHelper)]
  5. #[allow(dead_code)]
  6. struct WithFields {
  7. hello: (),
  8. dora: u32,
  9. my: String,
  10. name: f32,
  11. }
  12. #[test]
  13. fn test_with_fields() {
  14. let fields = WithFields {
  15. hello: (),
  16. dora: 0,
  17. my: "".to_string(),
  18. name: 0.0,
  19. }
  20. .__dir__();
  21. assert_eq!(
  22. vec![
  23. "hello".to_string(),
  24. "dora".to_string(),
  25. "my".to_string(),
  26. "name".to_string()
  27. ],
  28. fields
  29. );
  30. }
  31. #[pyclass]
  32. #[derive(DirHelper)]
  33. #[allow(dead_code)]
  34. struct UnitNoFields;
  35. #[test]
  36. fn test_no_fields() {
  37. let fields: Vec<String> = UnitNoFields.__dir__();
  38. assert_eq!(Vec::<String>::new(), fields);
  39. }