diff --git a/Cargo.toml b/Cargo.toml index a67af8b..8382753 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,3 +52,19 @@ harness = false [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[[example]] +name = "custom" +required-features = ["image"] + +[[example]] +name = "embed" +required-features = ["image"] + +[[example]] +name = "image" +required-features = ["image"] + +[[example]] +name = "svg" +required-features = ["svg"] diff --git a/examples/custom.rs b/examples/custom.rs index 3b7de38..ebd5f03 100644 --- a/examples/custom.rs +++ b/examples/custom.rs @@ -1,4 +1,3 @@ -#[cfg(all(feature = "image", feature = "svg"))] fn main() { use fast_qr::{ convert::{image::ImageBuilder, Builder, Shape}, @@ -38,8 +37,3 @@ fn main() { .background_color([255, 255, 255, 255]) .to_file(&qrcode, "custom.png"); } - -#[cfg(not(feature = "image"))] -fn main() { - compile_error!("Please enable the `image` features."); -} diff --git a/examples/embed.rs b/examples/embed.rs index 4f11d7c..cb1fb35 100644 --- a/examples/embed.rs +++ b/examples/embed.rs @@ -1,4 +1,3 @@ -#[cfg(all(feature = "image", feature = "svg"))] fn main() { use fast_qr::{ convert::{image::ImageBuilder, Builder, ImageBackgroundShape, Shape}, @@ -23,8 +22,3 @@ fn main() { .image_background_shape(ImageBackgroundShape::Square) .to_file(&qrcode, "embed.png"); } - -#[cfg(not(feature = "image"))] -fn main() { - compile_error!("Please enable the `image` features."); -} diff --git a/examples/image.rs b/examples/image.rs index 60bbc08..d81b9e2 100644 --- a/examples/image.rs +++ b/examples/image.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "image")] fn main() { use fast_qr::{ convert::{image::ImageBuilder, Builder, Shape}, @@ -24,8 +23,3 @@ fn main() { .background_color([255, 255, 255, 255]) // opaque .to_bytes(&qrcode); } - -#[cfg(not(feature = "image"))] -fn main() { - compile_error!("Please enable the `image` features."); -} diff --git a/examples/svg.rs b/examples/svg.rs index c52422b..c8ca145 100644 --- a/examples/svg.rs +++ b/examples/svg.rs @@ -1,4 +1,3 @@ -#[cfg(feature = "svg")] fn main() { use fast_qr::{ convert::{svg::SvgBuilder, Builder, Shape}, @@ -15,8 +14,3 @@ fn main() { .shape(Shape::RoundedSquare) .to_file(&qrcode, "svg.svg"); } - -#[cfg(not(feature = "svg"))] -fn main() { - eprintln!("Please enable the `svg` features.") -}