Improve documentation formatting for Broadcastable trait and element-wise comparison methods

This commit is contained in:
Palash Tyagi 2025-04-26 02:54:13 +01:00
parent 8ed8cecd0e
commit 1865e90956

View File

@ -202,8 +202,8 @@ pub enum Axis {
Row, Row,
} }
/// A trait to turn either a Matrix<T> or a scalar T into a Vec<T> of /// A trait to turn either a `Matrix<T>` or a scalar T into a `Vec<T>` of
/// length rows*cols (broadcasting the scalar). /// length `rows*cols` (broadcasting the scalar).
pub trait Broadcastable<T> { pub trait Broadcastable<T> {
fn to_vec(&self, rows: usize, cols: usize) -> Vec<T>; fn to_vec(&self, rows: usize, cols: usize) -> Vec<T>;
} }
@ -223,7 +223,7 @@ impl<T: Clone> Broadcastable<T> for Matrix<T> {
} }
/// Generates element-wise eq, lt, le, gt and ge methods /// Generates element-wise eq, lt, le, gt and ge methods
/// where the rhs can be a Matrix<T> or a scalar T. /// where the rhs can be a `Matrix<T>` or a scalar T.
macro_rules! impl_elementwise_cmp { macro_rules! impl_elementwise_cmp {
( (
$( $method:ident => $op:tt ),* $(,)? $( $method:ident => $op:tt ),* $(,)?
@ -231,7 +231,7 @@ macro_rules! impl_elementwise_cmp {
impl<T: PartialOrd + Clone> Matrix<T> { impl<T: PartialOrd + Clone> Matrix<T> {
$( $(
#[doc = concat!("Element-wise comparison `self ", stringify!($op), " rhs`,\n\ #[doc = concat!("Element-wise comparison `self ", stringify!($op), " rhs`,\n\
where `rhs` may be a Matrix<T> or a scalar T.")] where `rhs` may be a `Matrix<T>` or a scalar T.")]
pub fn $method<Rhs>(&self, rhs: Rhs) -> BoolMatrix pub fn $method<Rhs>(&self, rhs: Rhs) -> BoolMatrix
where where
Rhs: Broadcastable<T>, Rhs: Broadcastable<T>,