From 65e2f77624c24b969b40bb6f32105095cd9934c3 Mon Sep 17 00:00:00 2001 From: Andrew Lilley Brinker Date: Mon, 19 Feb 2024 23:32:29 +0000 Subject: [PATCH] feat: add top-level docs example. This commit adds a top-level example to the crate docs, and also fixes a broken link in the docs for ObjectType. Signed-off-by: Andrew Lilley Brinker --- gitoid/src/lib.rs | 12 ++++++++++++ gitoid/src/object_type.rs | 2 ++ 2 files changed, 14 insertions(+) diff --git a/gitoid/src/lib.rs b/gitoid/src/lib.rs index ef3a542..1aba6fc 100644 --- a/gitoid/src/lib.rs +++ b/gitoid/src/lib.rs @@ -90,6 +90,18 @@ //! the hash algorithm used and the object type being identified. These are //! defined by the [`HashAlgorithm`] and [`ObjectType`] traits. //! +//! ## Example +//! +//! ```rust +//! # use gitoid::{Sha256, Blob}; +//! +//! type GitOid = gitoid::GitOid; +//! +//! let gitoid: GitOid = gitoid::GitOid::from_str("hello, world"); +//! +//! println!("gitoid: {}", gitoid); +//! ``` +//! //! [gitoid]: https://git-scm.com/book/en/v2/Git-Internals-Git-Objects //! [omnibor]: https://omnibor.io diff --git a/gitoid/src/object_type.rs b/gitoid/src/object_type.rs index 9b38bd3..248d4ee 100644 --- a/gitoid/src/object_type.rs +++ b/gitoid/src/object_type.rs @@ -11,6 +11,8 @@ use crate::GitOid; /// /// For more information on sealed traits, read Predrag /// Gruevski's ["A Definitive Guide to Sealed Traits in Rust"][1]. +/// +/// [1]: https://predr.ag/blog/definitive-guide-to-sealed-traits-in-rust/ pub trait ObjectType: Sealed { #[doc(hidden)] const NAME: &'static str;