Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,20 @@ jobs:
components: rustfmt
- run: cargo fmt --all --check

doc:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
- run: cargo rustdoc -- --cfg docsrs

# One job that "summarizes" the success state of this pipeline. This can then be added to branch
# protection, rather than having to add each job separately.
success:
name: Success
runs-on: ubuntu-latest
needs: [test, no_std, clippy, fmt]
needs: [test, no_std, clippy, fmt, doc]
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "num-primitive"
version = "0.1.0"
version = "0.1.1"
description = "Traits for primitive numeric types"
repository = "https://github.com/rust-num/num-primitive"
license = "MIT OR Apache-2.0"
Expand All @@ -14,12 +14,17 @@ default = ["std"]
std = []

[lints.rust]
missing-docs = "deny"
private-bounds = "deny"
private-interfaces = "deny"
unconditional-recursion = "deny"
unnameable-types = "deny"
unreachable-pub = "deny"

[lints.rustdoc]
broken-intra-doc-links = "deny"
private-intra-doc-links = "deny"

[package.metadata.release]
allow-branch = ["main"]
sign-tag = true
4 changes: 4 additions & 0 deletions RELEASES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Release 0.1.1 (2025-12-11)

- Link documentation to inherent methods.

# Release 0.1.0 (2025-12-09)

- Initial release with MSRV 1.85.
1 change: 1 addition & 0 deletions src/float.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,7 @@ macro_rules! impl_float {

// NOTE: This is still effectively forwarding, but we need some indirection
// to avoid naming the unstable `core::convert::FloatToInt`.
#[doc = forward_doc!(to_int_unchecked)]
#[inline]
unsafe fn to_int_unchecked<Int>(self) -> Int
where
Expand Down
17 changes: 17 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
/// Forward a method to an inherent method
macro_rules! forward {
($(fn $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$(
#[doc = forward_doc!($method)]
#[inline]
fn $method(self $( , $arg : $ty )* ) -> $ret {
Self::$method(self $( , $arg )* )
}
)*};
($(fn $method:ident ( &self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$(
#[doc = forward_doc!($method)]
#[inline]
fn $method(&self $( , $arg : $ty )* ) -> $ret {
Self::$method(self $( , $arg )* )
}
)*};
($(fn $method:ident ( $( $arg:ident : $ty:ty ),* ) -> $ret:ty ; )*) => {$(
#[doc = forward_doc!($method)]
#[inline]
fn $method($( $arg : $ty ),* ) -> $ret {
Self::$method($( $arg ),* )
}
)*};
($(unsafe fn $method:ident ( self $( , $arg:ident : $ty:ty )* ) -> $ret:ty ; )*) => {$(
#[doc = forward_doc!($method)]
#[inline]
unsafe fn $method(self $( , $arg : $ty )* ) -> $ret {
// SAFETY: we're just passing through here!
Expand All @@ -27,6 +31,19 @@ macro_rules! forward {
)*};
}

/// A string suitable for method `#[doc = ...]`
macro_rules! forward_doc {
($method:ident) => {
concat!(
"See the inherent [`",
stringify!($method),
"`][Self::",
stringify!($method),
"] method."
)
};
}

/// Declare a `const` that copies an original value
macro_rules! use_consts {
($base:ident :: { $( $name:ident : $ty:ty ,)+ }) => {
Expand Down