Skip to content

Commit

Permalink
fix: use required-features for examples
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnTheCoolingFan authored and erwanvivien committed Oct 9, 2023
1 parent 501fc6c commit 24f9b25
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 24 deletions.
16 changes: 16 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
6 changes: 0 additions & 6 deletions examples/custom.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(all(feature = "image", feature = "svg"))]
fn main() {
use fast_qr::{
convert::{image::ImageBuilder, Builder, Shape},
Expand Down Expand Up @@ -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.");
}
6 changes: 0 additions & 6 deletions examples/embed.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(all(feature = "image", feature = "svg"))]
fn main() {
use fast_qr::{
convert::{image::ImageBuilder, Builder, ImageBackgroundShape, Shape},
Expand All @@ -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.");
}
6 changes: 0 additions & 6 deletions examples/image.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "image")]
fn main() {
use fast_qr::{
convert::{image::ImageBuilder, Builder, Shape},
Expand All @@ -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.");
}
6 changes: 0 additions & 6 deletions examples/svg.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "svg")]
fn main() {
use fast_qr::{
convert::{svg::SvgBuilder, Builder, Shape},
Expand All @@ -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.")
}

0 comments on commit 24f9b25

Please sign in to comment.