Skip to content

Commit

Permalink
ignore prost mod and fix clippy warning
Browse files Browse the repository at this point in the history
Signed-off-by: YangKeao <yangkeao@chunibyo.icu>
  • Loading branch information
YangKeao committed Aug 19, 2022
1 parent 3713016 commit 8fdcca3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Expand Up @@ -65,6 +65,7 @@ pub use self::report::{Report, ReportBuilder, UnresolvedReport};
#[cfg(feature = "flamegraph")]
pub use inferno::flamegraph;

#[allow(clippy::all)]
#[cfg(all(feature = "prost-codec", not(feature = "protobuf-codec")))]
pub mod protos {
pub use prost::Message;
Expand Down
13 changes: 7 additions & 6 deletions src/report.rs
Expand Up @@ -29,9 +29,11 @@ pub struct UnresolvedReport {
pub timing: ReportTiming,
}

type FramesPostProcessor = Box<dyn Fn(&mut Frames)>;

/// A builder of `Report` and `UnresolvedReport`. It builds report from a running `Profiler`.
pub struct ReportBuilder<'a> {
frames_post_processor: Option<Box<dyn Fn(&mut Frames)>>,
frames_post_processor: Option<FramesPostProcessor>,
profiler: &'a RwLock<Result<Profiler>>,
timing: ReportTiming,
}
Expand Down Expand Up @@ -159,13 +161,13 @@ impl Debug for Report {
mod flamegraph {
use super::*;
use inferno::flamegraph;
use std::io::Write;
use std::fmt::Write;

impl Report {
/// `flamegraph` will write an svg flamegraph into `writer` **only available with `flamegraph` feature**
pub fn flamegraph<W>(&self, writer: W) -> Result<()>
where
W: Write,
W: std::io::Write,
{
self.flamegraph_with_options(writer, &mut flamegraph::Options::default())
}
Expand All @@ -177,7 +179,7 @@ mod flamegraph {
options: &mut flamegraph::Options,
) -> Result<()>
where
W: Write,
W: std::io::Write,
{
let lines: Vec<String> = self
.data
Expand All @@ -188,8 +190,7 @@ mod flamegraph {

for frame in key.frames.iter().rev() {
for symbol in frame.iter().rev() {
line.push_str(&format!("{}", symbol));
line.push(';');
write!(&mut line, "{};", symbol).unwrap();
}
}

Expand Down

0 comments on commit 8fdcca3

Please sign in to comment.