Procházet zdrojové kódy

Merge pull request #4 from seanyoung/doctest

Fix doctest and run them during CI
Alessandro Decina před 3 roky
rodič
revize
521ef09463

+ 1 - 1
.github/workflows/build-test.yml

@@ -34,4 +34,4 @@ jobs:
         run: cargo build --verbose
 
       - name: Run tests
-        run: RUST_BACKTRACE=full cargo test --verbose --tests
+        run: RUST_BACKTRACE=full cargo test --verbose

+ 1 - 0
aya/src/maps/perf/async_perf_event_array.rs

@@ -40,6 +40,7 @@ use crate::maps::{
 /// #    #[error(transparent)]
 /// #    PerfBuf(#[from] aya::maps::perf::PerfBufferError),
 /// # }
+/// # #[cfg(feature = "async_tokio")]
 /// # async fn try_main() -> Result<(), Error> {
 /// # let bpf = aya::Bpf::load(&[], None)?;
 /// use aya::maps::perf::{AsyncPerfEventArray, PerfBufferError};

+ 17 - 5
aya/src/programs/lirc_mode2.rs

@@ -18,15 +18,27 @@ use libc::{close, dup};
 /// # Examples
 ///
 /// ```no_run
+/// # #[derive(thiserror::Error, Debug)]
+/// # enum Error {
+/// #     #[error(transparent)]
+/// #     IO(#[from] std::io::Error),
+/// #     #[error(transparent)]
+/// #     Map(#[from] aya::maps::MapError),
+/// #     #[error(transparent)]
+/// #     Program(#[from] aya::programs::ProgramError),
+/// #     #[error(transparent)]
+/// #     Bpf(#[from] aya::BpfError)
+/// # }
+/// # let mut bpf = aya::Bpf::load(&[], None)?;
 /// use std::fs::File;
 /// use std::convert::TryInto;
 /// use aya::programs::LircMode2;
 ///
-/// let file = File::open("/dev/lirc0").unwrap();
-/// let mut bpf = Bpf::load_file("imon_rsc.o").unwrap();
-/// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc").unwrap().try_into().unwrap();
-/// decoder.load().unwrap();
-/// decoder.attach(file).unwrap();
+/// let file = File::open("/dev/lirc0")?;
+/// let mut bpf = aya::Bpf::load_file("imon_rsc.o")?;
+/// let decoder: &mut LircMode2 = bpf.program_mut("imon_rsc")?.try_into().unwrap();
+/// decoder.load()?;
+/// decoder.attach(file)?;
 /// # Ok::<(), Error>(())
 /// ```
 #[derive(Debug)]