Skip to content

Commit

Permalink
Let the cargo.toml know which example requires which features (#511)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamo <tamo@meilisearch.com>
  • Loading branch information
irevoire authored May 3, 2024
1 parent f49c724 commit b7e8745
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 20 deletions.
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,11 @@ harness = false
[[bench]]
name = "text_encoder"
harness = false

[[example]]
name = "example_push"
required-features = ["push"]

[[example]]
name = "example_process_collector"
required-features = ["process"]
9 changes: 0 additions & 9 deletions examples/example_process_collector.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

#[cfg(all(feature = "process", target_os = "linux"))]
fn main() {
use std::thread;
use std::time::Duration;
Expand All @@ -21,11 +20,3 @@ fn main() {
thread::sleep(Duration::from_secs(1));
}
}

#[cfg(any(not(feature = "process"), not(target_os = "linux")))]
fn main() {
println!(
r#"Please enable feature "process", try:
cargo run --features="process" --example example_process_collector"#
);
}
11 changes: 0 additions & 11 deletions examples/example_push.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.

#![cfg_attr(not(feature = "push"), allow(unused_imports, dead_code))]

use std::env;
use std::thread;
use std::time;
Expand All @@ -25,7 +23,6 @@ lazy_static! {
.unwrap();
}

#[cfg(feature = "push")]
fn main() {
let args: Vec<String> = env::args().collect();
let program = args[0].clone();
Expand Down Expand Up @@ -68,11 +65,3 @@ fn main() {

println!("Okay, please check the Pushgateway.");
}

#[cfg(not(feature = "push"))]
fn main() {
println!(
r#"Please enable feature "push", try:
cargo run --features="push" --example example_push"#
);
}

0 comments on commit b7e8745

Please sign in to comment.