From 482431b1af72e6852904933b28e0b2d49e13d883 Mon Sep 17 00:00:00 2001 From: Marcel Hellwig Date: Thu, 15 Nov 2018 09:54:06 +0100 Subject: [PATCH] extend doc --- src/lib.rs | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index a498bf7..719acae 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,12 +21,16 @@ //! //! Afterwards you can use it in your 2018-rust-project //! -//! ```rust,ignore -//! use logical +//! ```rust +//! use logical; //! ``` //! //! # Example: connect one port to an other //! +//! Normally you will connect one [`Port`] to one [`Signal`] as input and then connect an other port as +//! output to that same signal. On [`Updateable::update`] the value from the input will be transfered to +//! the output. +//! //! ```rust //! use logical::{Ieee1164, Port, Signal, Updateable}; //! use logical::direction::{Input, Output}; @@ -43,6 +47,28 @@ //! assert_eq!(Ieee1164::from('1'), to.value()); //! ``` //! +//! # Example: multiple ports +//! +//! If you have more than one connector the value on the signal will be determined based on the +//! [`Resolve`] trait. In this case a high-impedance value will be overriden by the Strong zero +//! value and therefore result in 0. +//! +//! ```rust +//! use logical::{Ieee1164, Port, Signal, Updateable}; +//! use logical::direction::{Input, Output}; +//! +//! let from1 = Port::<_, Output>::new(Ieee1164::from('z')); +//! let from2 = Port::<_, Output>::new(Ieee1164::from('0')); +//! let to = Port::<_, Input>::default(); +//! let mut signal = Signal::new(); +//! +//! signal.connect_as_input(&from1); +//! signal.connect_as_input(&from2); +//! signal.connect_as_output(&to); +//! +//! signal.update(); +//! +//! assert_eq!(Ieee1164::from('0'), to.value()); #[macro_use] mod mac;