From 0165f2101e5bce5bc9af5c2b525e1f60a865160f Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 28 Aug 2022 12:38:58 -0500 Subject: [PATCH] Improve links in docs for generated named arguments structs Probably needs https://github.com/rust-lang/rust/issues/74563 for the original intended behaviour. --- binrw/src/binread/impls.rs | 2 +- binrw_derive/src/codegen/typed_builder.rs | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/binrw/src/binread/impls.rs b/binrw/src/binread/impls.rs index f6fd9628..a5e1584b 100644 --- a/binrw/src/binread/impls.rs +++ b/binrw/src/binread/impls.rs @@ -88,7 +88,7 @@ binread_nonzero_impl! { NonZeroI8, i8, NonZeroI16, i16, NonZeroI32, i32, NonZeroI64, i64, NonZeroI128, i128, } -/// Named arguments for [`Vec::read_options()`]. +/// Named arguments for the [`BinRead::read_options()`] implementation of [`Vec`]. /// /// # Examples /// diff --git a/binrw_derive/src/codegen/typed_builder.rs b/binrw_derive/src/codegen/typed_builder.rs index b935f2ab..96963b44 100644 --- a/binrw_derive/src/codegen/typed_builder.rs +++ b/binrw_derive/src/codegen/typed_builder.rs @@ -48,14 +48,16 @@ impl<'a> Builder<'a> { let res_struct = if define_result { let docs = self.owner_name.map(|owner_name| { + let (impl_name, impl_fn) = if self.is_write { + ("BinWrite", "write_options") + } else { + ("BinRead", "read_options") + }; format!( - "Named arguments for [`{}::{}`].", + "Named arguments for the [`{0}::{1}`](::binrw::{0}::{1}) implementation of [`{2}`].", + impl_name, + impl_fn, owner_name, - if self.is_write { - "write_options" - } else { - "read_options" - } ) });