From 70a2b62c50087fa6df5070ab696c5a355072cb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kh=E1=BA=A3i?= Date: Tue, 31 Oct 2023 05:28:56 +0700 Subject: [PATCH] Add simpler code snippet to the documentation (#515) Co-authored-by: Tony Arcieri --- sha1/src/lib.rs | 12 ++++++++++++ sha2/src/lib.rs | 14 ++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/sha1/src/lib.rs b/sha1/src/lib.rs index 38ddc4b51..25e867e0f 100644 --- a/sha1/src/lib.rs +++ b/sha1/src/lib.rs @@ -11,6 +11,18 @@ //! //! # Usage //! +//! ## One-shot API +//! +//! ```rust +//! use hex_literal::hex; +//! use sha1::{Sha1, Digest}; +//! +//! let result = Sha1::digest(b"hello world"); +//! assert_eq!(result[..], hex!("2aae6c35c94fcfb415dbe95f408b9ce91ee846ed")); +//! ``` +//! +//! ## Incremental API +//! //! ```rust //! use hex_literal::hex; //! use sha1::{Sha1, Digest}; diff --git a/sha2/src/lib.rs b/sha2/src/lib.rs index a3482e84a..c178d4eb4 100644 --- a/sha2/src/lib.rs +++ b/sha2/src/lib.rs @@ -11,6 +11,20 @@ //! //! # Usage //! +//! ## One-shot API +//! +//! ```rust +//! use hex_literal::hex; +//! use sha2::{Sha256, Digest}; +//! +//! let result = Sha256::digest(b"hello world"); +//! assert_eq!(result[..], hex!(" +//! b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9 +//! ")[..]); +//! ``` +//! +//! ## Incremental API +//! //! ```rust //! use hex_literal::hex; //! use sha2::{Sha256, Sha512, Digest};