-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
85 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![allow(clippy::derive_partial_eq_without_eq, clippy::get_first)] | ||
#![deny(unused_crate_dependencies)] | ||
#![warn(clippy::used_underscore_binding)] | ||
|
||
extern crate self as fastn_jdebug; | ||
|
||
pub trait JDebug { | ||
fn debug(&self, source: &str) -> serde_json::Value; | ||
} | ||
|
||
impl<T: fastn_jdebug::JDebug> fastn_jdebug::JDebug for Vec<T> { | ||
fn debug(&self, source: &str) -> serde_json::Value { | ||
serde_json::Value::Array(self.iter().map(|v| v.debug(source)).collect()) | ||
} | ||
} | ||
|
||
impl<T: fastn_jdebug::JDebug> fastn_jdebug::JDebug for Option<T> { | ||
fn debug(&self, source: &str) -> serde_json::Value { | ||
self.as_ref() | ||
.map(|v| v.debug(source)) | ||
.unwrap_or(serde_json::Value::Null) | ||
} | ||
} | ||
|
||
impl<K: AsRef<std::ops::Range<usize>>, V: fastn_jdebug::JDebug> fastn_jdebug::JDebug | ||
for std::collections::HashMap<K, V> | ||
{ | ||
fn debug(&self, source: &str) -> serde_json::Value { | ||
let mut o = serde_json::Map::new(); | ||
for (k, v) in self { | ||
let r = k.as_ref(); | ||
o.insert(source[r.start..r.end].to_string(), v.debug(source)); | ||
} | ||
serde_json::Value::Object(o) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters