mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-27 04:44:30 +00:00
16 lines
282 B
Rust
16 lines
282 B
Rust
|
pub use serde_json::*;
|
||
|
|
||
|
pub trait ToJson {
|
||
|
fn to_json(&self) -> Value;
|
||
|
}
|
||
|
|
||
|
impl<T: ToJson> ToJson for Option<T> {
|
||
|
fn to_json(&self) -> Value {
|
||
|
if let Some(value) = self.as_ref() {
|
||
|
value.to_json()
|
||
|
} else {
|
||
|
json!(null)
|
||
|
}
|
||
|
}
|
||
|
}
|