summaryrefslogtreecommitdiffstats
path: root/src/lib.rs
diff options
context:
space:
mode:
authorAgathe Porte <microjoe@microjoe.org>2020-02-27 12:51:56 +0100
committerAgathe Porte <microjoe@microjoe.org>2020-02-27 12:51:56 +0100
commit9df0a6e9061d65220df91578e7442a75a9727361 (patch)
tree4df2717c10a2655cffe402d25d5ea575ef8b047c /src/lib.rs
parent3110d3fa3a2a5a17fd467b30a4acaeab9ff8b978 (diff)
downloadcharlcd-9df0a6e9061d65220df91578e7442a75a9727361.tar.gz
charlcd-9df0a6e9061d65220df91578e7442a75a9727361.zip
lib: make the doctest pass
Not very happy with the provided examples, because we need to use the FileScreen::default for the examples to work instead of the Screen::default that works in the examples. To be retried on nightly and maybe file up a bug report.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs45
1 files changed, 34 insertions, 11 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 49a32b0..0eacbfc 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -22,16 +22,21 @@ use codes::WriteInto;
///
/// # Simple example
///
-/// ```rust
+/// ```no_run
+/// extern crate charlcd;
+///
/// use charlcd::Screen;
+/// use std::io::Write;
///
/// fn main() -> std::io::Result<()> {
-/// let mut screen = Screen::default(); // will use "/dev/lcd" charlcd driver
+/// let mut screen = Screen::default()?; // will use "/dev/lcd" charlcd driver
///
/// screen.clear()?;
/// screen.write(b"hello, world!")?;
/// screen.flash_backlight()?;
/// screen.flush()?; // send all the previous commands to the driver at once
+///
+/// Ok(())
/// }
/// ```
pub struct Screen<T> {
@@ -330,7 +335,7 @@ where
// Concrete screen based on a File, to write to the real charlcd driver (or to
// another file).
-type FileScreen = Screen<BufWriter<File>>;
+pub type FileScreen = Screen<BufWriter<File>>;
const DEFAULT_SCREEN_DEV_PATH: &str = "/dev/lcd";
@@ -352,10 +357,19 @@ impl FileScreen {
///
/// # Example
///
- /// ```rust
- /// let screen = Screen::default()?; // the screen is 20x4 in this test
- /// let width = screen.width()?;
- /// assert_eq!(width, 20);
+ /// ```no_run
+ /// extern crate charlcd;
+ ///
+ /// use charlcd::FileScreen;
+ ///
+ /// fn main() -> std::io::Result<()> {
+ /// let screen = FileScreen::default()?; // the screen is 20x4 in this test
+ ///
+ /// let width = screen.width()?;
+ /// assert_eq!(width, 20);
+ ///
+ /// Ok(())
+ /// }
/// ```
///
/// # Important note
@@ -378,10 +392,19 @@ impl FileScreen {
///
/// # Example
///
- /// ```rust
- /// let screen = Screen::default()?; // the screen is 20x4 in this test
- /// let width = screen.height()?;
- /// assert_eq!(width, 4);
+ /// ```no_run
+ /// extern crate charlcd;
+ ///
+ /// use charlcd::FileScreen;
+ ///
+ /// fn main() -> std::io::Result<()> {
+ /// let screen = FileScreen::default()?; // the screen is 20x4 in this test
+ ///
+ /// let height = screen.height()?;
+ /// assert_eq!(height, 4);
+ ///
+ /// Ok(())
+ /// }
/// ```
///
/// # Important note