chiark / gitweb /
Minimal docs improvements.
authorSimon Tatham <anakin@pobox.com>
Sat, 12 Apr 2025 12:18:10 +0000 (13:18 +0100)
committerSimon Tatham <anakin@pobox.com>
Sat, 12 Apr 2025 12:19:01 +0000 (13:19 +0100)
src/finitenimber.rs

index c87fe1bc479c062e18793156ec454079d9cc3a90..b7ea0bb62916195be5cdb536fd9e13c4f7c261f7 100644 (file)
@@ -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<Word>);
 
@@ -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<FiniteNimberRef<'a>> 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())