From 29852fbb3de95bf60eff4be316df09c55d07313f Mon Sep 17 00:00:00 2001 From: Yang Keao Date: Tue, 15 Dec 2020 17:59:52 +0800 Subject: [PATCH] support stable rust Signed-off-by: Yang Keao --- Cargo.toml | 3 ++- src/lib.rs | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 65be5ce7..d4c521d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,7 @@ default = ["cpp"] flamegraph = ["inferno"] protobuf = ["prost", "prost-derive", "prost-build"] cpp = ["symbolic-demangle/cpp"] +heap = [] [dependencies] backtrace = "0.3" @@ -55,7 +56,7 @@ required-features = ["flamegraph"] [[example]] name = "heap_profiler" -required-features = ["protobuf", "flamegraph"] +required-features = ["protobuf", "flamegraph", "heap"] [[bench]] name = "collector" diff --git a/src/lib.rs b/src/lib.rs index f1317065..115b0ffe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,7 +21,7 @@ //!}; //! ``` -#![feature(const_fn)] +#![cfg_attr(feature = "heap", feature(const_fn))] /// Define the MAX supported stack depth. TODO: make this variable mutable. pub const MAX_DEPTH: usize = 32; @@ -32,7 +32,9 @@ pub const MAX_THREAD_NAME: usize = 16; mod collector; mod error; mod frames; +#[cfg(feature = "heap")] mod heap_profiler; + mod profiler; mod report; mod timer; @@ -40,7 +42,10 @@ mod timer; pub use self::collector::{Collector, StackHashCounter}; pub use self::error::{Error, Result}; pub use self::frames::{Frames, Symbol}; + +#[cfg(feature = "heap")] pub use self::heap_profiler::{AllocRecorder, HeapProfilerGuard}; + pub use self::profiler::ProfilerGuard; pub use self::report::{Report, ReportBuilder};