Skip to content

Commit 61318d9

Browse files
authored
use Uuid:::from_u128 for uuid_to_string (#1362)
1 parent 9f7bf4c commit 61318d9

File tree

1 file changed

+6
-2
lines changed
  • src/serializers/type_serializers

1 file changed

+6
-2
lines changed

src/serializers/type_serializers/uuid.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
use std::borrow::Cow;
22

3-
use pyo3::prelude::*;
43
use pyo3::types::PyDict;
4+
use pyo3::{intern, prelude::*};
5+
use uuid::Uuid;
56

67
use crate::definitions::DefinitionsBuilder;
78

@@ -11,7 +12,10 @@ use super::{
1112
};
1213

1314
pub(crate) fn uuid_to_string(py_uuid: &Bound<'_, PyAny>) -> PyResult<String> {
14-
Ok(py_uuid.str()?.to_string())
15+
let py = py_uuid.py();
16+
let uuid_int_val: u128 = py_uuid.getattr(intern!(py, "int"))?.extract()?;
17+
let uuid = Uuid::from_u128(uuid_int_val);
18+
Ok(uuid.to_string())
1519
}
1620

1721
#[derive(Debug, Clone)]

0 commit comments

Comments
 (0)