From: Simon Tatham Date: Sat, 12 Apr 2025 12:18:10 +0000 (+0100) Subject: Minimal docs improvements. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=dc5dbec9caa6b5308216a0589de5e0b072d4abb7;p=nimber.git Minimal docs improvements. --- diff --git a/src/finitenimber.rs b/src/finitenimber.rs index c87fe1b..b7ea0bb 100644 --- a/src/finitenimber.rs +++ b/src/finitenimber.rs @@ -7,6 +7,7 @@ use itertools::Itertools; pub type Word = u64; // element type of the vectors we use const WORDLEVELS: usize = 6; // 2^{2^6} = 64 = size of Word +/// A type representing a finite nimber. #[derive(Clone, PartialEq, Eq, Hash)] pub struct FiniteNimber(Vec); @@ -396,16 +397,6 @@ impl<'a> FiniteNimberRef<'a> { } } -impl FiniteNimber { - /// Compute the square of a nimber, faster than the general - /// multiplication algorithm performed by the `Mul` trait can do - /// it. - pub fn square(&self) -> FiniteNimber { - let r = self.to_ref(); - r.square_recurse(r.level()) - } -} - impl<'a, 'b> Mul> for FiniteNimberRef<'b> { type Output = FiniteNimber; fn mul(self, other: FiniteNimberRef<'a>) -> FiniteNimber { @@ -467,10 +458,18 @@ impl<'a> FiniteNimberRef<'a> { } impl FiniteNimber { + /// Compute the square of a nimber, faster than the general + /// multiplication algorithm performed by the `Mul` trait can do + /// it. + pub fn square(&self) -> FiniteNimber { + let r = self.to_ref(); + r.square_recurse(r.level()) + } + /// Compute the square root of a nimber. Every nimber has a unique - /// square root, so this function can't fail, and doesn't need to - /// return a list or a tuple or anything more complicated than a - /// single nimber. + /// square root, and the square root of a finite nimber is finite. + /// So this function can't fail, and doesn't need to return a list + /// or a tuple or anything more complicated than a single nimber. pub fn sqrt(&self) -> FiniteNimber { let r = self.to_ref(); r.sqrt_recurse(r.level())