aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Krahl <robin.krahl@ireas.org>2019-12-27 23:08:29 +0100
committerRobin Krahl <robin.krahl@ireas.org>2019-12-27 23:08:29 +0100
commit4467ce7a2d1eedb320e92e5a26f1b93bc41d3611 (patch)
tree6eff6a4a13d6bed240b021c9c6c8fae45b9a957e
parentc35a20f6c034e4d8aa1eeba3eef85429e09d95dc (diff)
downloadnitrokey-rs-4467ce7a2d1eedb320e92e5a26f1b93bc41d3611.tar.gz
nitrokey-rs-4467ce7a2d1eedb320e92e5a26f1b93bc41d3611.tar.bz2
Simplify doc tests with results
Since Rust 1.34.0, we no longer need a `fn main` comment in doc tests that return results. It is sufficient to have an `Ok` return value with type annotations.
-rw-r--r--src/device/mod.rs4
-rw-r--r--src/lib.rs20
2 files changed, 6 insertions, 18 deletions
diff --git a/src/device/mod.rs b/src/device/mod.rs
index af28ab5..5e15f08 100644
--- a/src/device/mod.rs
+++ b/src/device/mod.rs
@@ -78,13 +78,11 @@ pub trait Device<'a>: Authenticate<'a> + GetPasswordSafe<'a> + GenerateOtp + fmt
/// // ...
/// }
///
- /// # fn main() -> Result<(), nitrokey::Error> {
/// match nitrokey::take()?.connect() {
/// Ok(device) => do_something(device),
/// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
/// }
- /// # Ok(())
- /// # }
+ /// # Ok::<(), nitrokey::Error>(())
/// ```
fn into_manager(self) -> &'a mut crate::Manager;
diff --git a/src/lib.rs b/src/lib.rs
index a4402c5..059792d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -243,14 +243,12 @@ impl Manager {
///
/// fn do_something(device: DeviceWrapper) {}
///
- /// # fn main() -> Result<(), nitrokey::Error> {
/// let mut manager = nitrokey::take()?;
/// match manager.connect() {
/// Ok(device) => do_something(device),
/// Err(err) => println!("Could not connect to a Nitrokey: {}", err),
/// }
- /// # Ok(())
- /// # }
+ /// # Ok::<(), nitrokey::Error>(())
/// ```
///
/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
@@ -276,13 +274,11 @@ impl Manager {
///
/// fn do_something(device: DeviceWrapper) {}
///
- /// # fn main() -> Result<(), nitrokey::Error> {
/// match nitrokey::take()?.connect_model(Model::Pro) {
/// Ok(device) => do_something(device),
/// Err(err) => println!("Could not connect to a Nitrokey Pro: {}", err),
/// }
- /// # Ok(())
- /// # }
+ /// # Ok::<(), nitrokey::Error>(())
/// ```
///
/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
@@ -307,13 +303,11 @@ impl Manager {
///
/// fn use_pro(device: Pro) {}
///
- /// # fn main() -> Result<(), nitrokey::Error> {
/// match nitrokey::take()?.connect_pro() {
/// Ok(device) => use_pro(device),
/// Err(err) => println!("Could not connect to the Nitrokey Pro: {}", err),
/// }
- /// # Ok(())
- /// # }
+ /// # Ok::<(), nitrokey::Error>(())
/// ```
///
/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
@@ -338,13 +332,11 @@ impl Manager {
///
/// fn use_storage(device: Storage) {}
///
- /// # fn main() -> Result<(), nitrokey::Error> {
/// match nitrokey::take()?.connect_storage() {
/// Ok(device) => use_storage(device),
/// Err(err) => println!("Could not connect to the Nitrokey Storage: {}", err),
/// }
- /// # Ok(())
- /// # }
+ /// # Ok::<(), nitrokey::Error>(())
/// ```
///
/// [`NotConnected`]: enum.CommunicationError.html#variant.NotConnected
@@ -453,11 +445,9 @@ pub fn set_log_level(level: LogLevel) {
/// # Example
///
/// ```
-/// # fn main() -> Result<(), nitrokey::Error> {
/// let version = nitrokey::get_library_version()?;
/// println!("Using libnitrokey {}", version.git);
-/// # Ok(())
-/// # }
+/// # Ok::<(), nitrokey::Error>(())
/// ```
///
/// [`Utf8Error`]: enum.Error.html#variant.Utf8Error