'How to Use String instead of ObjectId in "wither" Rust?
I have this code here:
pub struct Account {
#[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
pub id: Option<ObjectId>,
pub email: String,
}
And I want to change "ObjectId" to String so I can use Ulid.
Solution 1:[1]
If you need String use
let str_id: String = account.id.unwrap().to_hex();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Barrrettt |