Std

Mainly a port of Rust's std.
git clone https://git.philomathiclife.com/repos/Std
Log | Files | Refs | README

Functions.cs (48177B)


      1 using Std.Clone;
      2 using Std.Cmp;
      3 using static Std.Cmp.Ordering;
      4 using Std.Convert;
      5 using Std.Hashing;
      6 using Std.Maybe;
      7 using System;
      8 using System.Text;
      9 #region Namespaces
     10 namespace Std {
     11     #region Types
     12     public static class Functions {
     13 
     14         #region Type-level Constructors
     15         #endregion
     16 
     17         #region Instance Constructors
     18         #endregion
     19 
     20         #region Type-level Fields
     21         #endregion
     22 
     23         #region Instance Fields
     24         #endregion
     25 
     26         #region Type-level Properties
     27         #endregion
     28 
     29         #region Instance Properties
     30         #endregion
     31 
     32         #region Type-level Functions
     33         public static T[] Clone<T>(this T[] self) where T: notnull, IClone<T> {
     34 
     35             var val = new T[self.Length];
     36 
     37             for (var i = 0; i < val.Length; i++) {
     38                 val[i] = self[i].Clone();
     39             }
     40             return val;
     41         }
     42         public static Prod<T0> Clone<T0>(this Prod<T0> self) where T0: notnull, IClone<T0> => new(self.Item0.Clone());
     43         public static Prod<T0, T1> Clone<T0, T1>(this Prod<T0, T1> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> => new(self.Item0.Clone(), self.Item1.Clone());
     44         public static Prod<T0, T1, T2> Clone<T0, T1, T2>(this Prod<T0, T1, T2> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> where T2: notnull, IClone<T2> => new(self.Item0.Clone(), self.Item1.Clone(), self.Item2.Clone());
     45         public static Prod<T0, T1, T2, T3> Clone<T0, T1, T2, T3>(this Prod<T0, T1, T2, T3> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> where T2: notnull, IClone<T2> where T3: notnull, IClone<T3> => new(self.Item0.Clone(), self.Item1.Clone(), self.Item2.Clone(), self.Item3.Clone());
     46         public static ProdMut<T0> Clone<T0>(this ProdMut<T0> self) where T0: notnull, IClone<T0> => new(self.Item0.Clone());
     47         public static ProdMut<T0, T1> Clone<T0, T1>(this ProdMut<T0, T1> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> => new(self.Item0.Clone(), self.Item1.Clone());
     48         public static ProdMut<T0, T1, T2> Clone<T0, T1, T2>(this ProdMut<T0, T1, T2> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> where T2: notnull, IClone<T2> => new(self.Item0.Clone(), self.Item1.Clone(), self.Item2.Clone());
     49         public static ProdMut<T0, T1, T2, T3> Clone<T0, T1, T2, T3>(this ProdMut<T0, T1, T2, T3> self) where T0: notnull, IClone<T0> where T1: notnull, IClone<T1> where T2: notnull, IClone<T2> where T3: notnull, IClone<T3> => new(self.Item0.Clone(), self.Item1.Clone(), self.Item2.Clone(), self.Item3.Clone());
     50         public static Ordering Cmp<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IOrd<T0> where TSelf: notnull, IProduct<T0> => self.Field0.Cmp(other.Field0);
     51         public static Ordering Cmp<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IOrd<T0> where T1: notnull, IOrd<T1> where TSelf: notnull, IProduct<T0, T1> {
     52 
     53             var val = self.Field0.Cmp(other.Field0);
     54             return val.Var != Ord.Equivalent ? val : self.Field1.Cmp(other.Field1);
     55         }
     56         public static Ordering Cmp<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IOrd<T0> where T1: notnull, IOrd<T1> where T2: notnull, IOrd<T2> where TSelf: notnull, IProduct<T0, T1, T2> {
     57 
     58             var val = self.Field0.Cmp(other.Field0);
     59 
     60             if (val.Var != Ord.Equivalent) {
     61                 return val;
     62             } else {
     63                 val = self.Field1.Cmp(other.Field1);
     64                 return val.Var != Ord.Equivalent ? val : self.Field2.Cmp(other.Field2);
     65             }
     66         }
     67         public static Ordering Cmp<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IOrd<T0> where T1: notnull, IOrd<T1> where T2: notnull, IOrd<T2> where T3: notnull, IOrd<T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
     68 
     69             var val = self.Field0.Cmp(other.Field0);
     70 
     71             if (val.Var != Ord.Equivalent) {
     72                 return val;
     73             } else {
     74                 val = self.Field1.Cmp(other.Field1);
     75 
     76                 if (val.Var != Ord.Equivalent) {
     77                     return val;
     78                 } else {
     79                     val = self.Field2.Cmp(other.Field2);
     80                     return val.Var != Ord.Equivalent ? val : self.Field3.Cmp(other.Field3);
     81                 }
     82             }
     83         }
     84         public static int CompareToComparable<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IComparable<T0> where TSelf: notnull, IProduct<T0> => self.Field0.CompareTo(other.Field0);
     85         public static int CompareToComparable<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IComparable<T0> where T1: notnull, IComparable<T1> where TSelf: notnull, IProduct<T0, T1> {
     86 
     87             var val = self.Field0.CompareTo(other.Field0);
     88             return val != 0 ? val : self.Field1.CompareTo(other.Field1);
     89         }
     90         public static int CompareToComparable<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IComparable<T0> where T1: notnull, IComparable<T1> where T2: notnull, IComparable<T2> where TSelf: notnull, IProduct<T0, T1, T2> {
     91 
     92             var val = self.Field0.CompareTo(other.Field0);
     93 
     94             if (val != 0) {
     95                 return val;
     96             } else {
     97                 val = self.Field1.CompareTo(other.Field1);
     98                 return val != 0 ? val : self.Field2.CompareTo(other.Field2);
     99             }
    100         }
    101         public static int CompareToComparable<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IComparable<T0> where T1: notnull, IComparable<T1> where T2: notnull, IComparable<T2> where T3: notnull, IComparable<T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    102 
    103             var val = self.Field0.CompareTo(other.Field0);
    104 
    105             if (val != 0) {
    106                 return val;
    107             } else {
    108                 val = self.Field1.CompareTo(other.Field1);
    109 
    110                 if (val != 0) {
    111                     return val;
    112                 } else {
    113                     val = self.Field2.CompareTo(other.Field2);
    114                     return val != 0 ? val : self.Field3.CompareTo(other.Field3);
    115                 }
    116             }
    117         }
    118         public static bool Eq<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 == other.Field0;
    119         public static bool Eq<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where TSelf: notnull, IProduct<T0, T1> => self.Field0 == other.Field0 && self.Field1 == other.Field1;
    120         public static bool Eq<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where T2: notnull, IPartialEq<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> => self.Field0 == other.Field0 && self.Field1 == other.Field1 && self.Field2 == other.Field2;
    121         public static bool Eq<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where T2: notnull, IPartialEq<T2, T2> where T3: notnull, IPartialEq<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> => self.Field0 == other.Field0 && self.Field1 == other.Field1 && self.Field2 == other.Field2 && self.Field3 == other.Field3;
    122         public static bool EqualsEquality<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IEquality<T0> where TSelf: notnull, IProduct<T0> => self.Field0.Equals(other.Field0);
    123         public static bool EqualsEquality<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IEquality<T0> where T1: notnull, IEquality<T1> where TSelf: notnull, IProduct<T0, T1> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1);
    124         public static bool EqualsEquality<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IEquality<T0> where T1: notnull, IEquality<T1> where T2: notnull, IEquality<T2> where TSelf: notnull, IProduct<T0, T1, T2> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1) && self.Field2.Equals(other.Field2);
    125         public static bool EqualsEquality<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IEquality<T0> where T1: notnull, IEquality<T1> where T2: notnull, IEquality<T2> where T3: notnull, IEquality<T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1) && self.Field2.Equals(other.Field2) && self.Field3.Equals(other.Field3);
    126         public static bool EqualsEquatable<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IEquatable<T0> where TSelf: notnull, IProduct<T0> => self.Field0.Equals(other.Field0);
    127         public static bool EqualsEquatable<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where TSelf: notnull, IProduct<T0, T1> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1);
    128         public static bool EqualsEquatable<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where T2: notnull, IEquatable<T2> where TSelf: notnull, IProduct<T0, T1, T2> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1) && self.Field2.Equals(other.Field2);
    129         public static bool EqualsEquatable<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where T2: notnull, IEquatable<T2> where T3: notnull, IEquatable<T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> => self.Field0.Equals(other.Field0) && self.Field1.Equals(other.Field1) && self.Field2.Equals(other.Field2) && self.Field3.Equals(other.Field3);
    130         public static bool Ge<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 >= other.Field0;
    131         public static bool Ge<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where TSelf: notnull, IProduct<T0, T1> {
    132 
    133             var val = self.Field0.PartialCmp(other.Field0);
    134 
    135             if (val.IsNone) {
    136                 return false;
    137             } else if (val._some.Var != Ord.Equivalent) {
    138                 return val._some.Var == Ord.Greater;
    139             } else {
    140                 val = self.Field1.PartialCmp(other.Field1);
    141                 return val.IsSome && val._some.Var != Ord.Less;
    142             }
    143         }
    144         public static bool Ge<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> {
    145 
    146             var val = self.Field0.PartialCmp(other.Field0);
    147 
    148             if (val.IsNone) {
    149                 return false;
    150             } else if (val._some.Var != Ord.Equivalent) {
    151                 return val._some.Var == Ord.Greater;
    152             } else {
    153                 val = self.Field1.PartialCmp(other.Field1);
    154 
    155                 if (val.IsNone) {
    156                     return false;
    157                 } else if (val._some.Var != Ord.Equivalent) {
    158                     return val._some.Var == Ord.Greater;
    159                 } else {
    160                     val = self.Field2.PartialCmp(other.Field2);
    161                     return val.IsSome && val._some.Var != Ord.Less;
    162                 }
    163             }
    164         }
    165         public static bool Ge<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where T3: notnull, IPartialOrd<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    166 
    167             var val = self.Field0.PartialCmp(other.Field0);
    168 
    169             if (val.IsNone) {
    170                 return false;
    171             } else if (val._some.Var != Ord.Equivalent) {
    172                 return val._some.Var == Ord.Greater;
    173             } else {
    174                 val = self.Field1.PartialCmp(other.Field1);
    175 
    176                 if (val.IsNone) {
    177                     return false;
    178                 } else if (val._some.Var != Ord.Equivalent) {
    179                     return val._some.Var == Ord.Greater;
    180                 } else {
    181                     val = self.Field2.PartialCmp(other.Field2);
    182 
    183                     if (val.IsNone) {
    184                         return false;
    185                     } else if (val._some.Var != Ord.Equivalent) {
    186                         return val._some.Var == Ord.Greater;
    187                     } else {
    188                         val = self.Field3.PartialCmp(other.Field3);
    189                         return val.IsSome && val._some.Var != Ord.Less;
    190                     }
    191                 }
    192             }
    193         }
    194         public static int GetHashCodeEquatable<TSelf, T0>(this TSelf self) where T0: notnull, IEquatable<T0> where TSelf: notnull, IProduct<T0> => self.Field0.GetHashCode();
    195         public static int GetHashCodeEquatable<TSelf, T0, T1>(this TSelf self) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where TSelf: notnull, IProduct<T0, T1> => HashCode.Combine(self.Field0, self.Field1);
    196         public static int GetHashCodeEquatable<TSelf, T0, T1, T2>(this TSelf self) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where T2: notnull, IEquatable<T2> where TSelf: notnull, IProduct<T0, T1, T2> => HashCode.Combine(self.Field0, self.Field1, self.Field2);
    197         public static int GetHashCodeEquatable<TSelf, T0, T1, T2, T3>(this TSelf self) where T0: notnull, IEquatable<T0> where T1: notnull, IEquatable<T1> where T2: notnull, IEquatable<T2> where T3: notnull, IEquatable<T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> => HashCode.Combine(self.Field0, self.Field1, self.Field2, self.Field3);
    198         public static bool Gt<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 > other.Field0;
    199         public static bool Gt<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where TSelf: notnull, IProduct<T0, T1> {
    200 
    201             var val = self.Field0.PartialCmp(other.Field0);
    202 
    203             if (val.IsNone) {
    204                 return false;
    205             } else if (val._some.Var != Ord.Equivalent) {
    206                 return val._some.Var == Ord.Greater;
    207             } else {
    208                 val = self.Field1.PartialCmp(other.Field1);
    209                 return val.IsSome && val._some.Var == Ord.Greater;
    210             }
    211         }
    212         public static bool Gt<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> {
    213 
    214             var val = self.Field0.PartialCmp(other.Field0);
    215 
    216             if (val.IsNone) {
    217                 return false;
    218             } else if (val._some.Var != Ord.Equivalent) {
    219                 return val._some.Var == Ord.Greater;
    220             } else {
    221                 val = self.Field1.PartialCmp(other.Field1);
    222 
    223                 if (val.IsNone) {
    224                     return false;
    225                 } else if (val._some.Var != Ord.Equivalent) {
    226                     return val._some.Var == Ord.Greater;
    227                 } else {
    228                     val = self.Field2.PartialCmp(other.Field2);
    229                     return val.IsSome && val._some.Var == Ord.Greater;
    230                 }
    231             }
    232         }
    233         public static bool Gt<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where T3: notnull, IPartialOrd<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    234 
    235             var val = self.Field0.PartialCmp(other.Field0);
    236 
    237             if (val.IsNone) {
    238                 return false;
    239             } else if (val._some.Var != Ord.Equivalent) {
    240                 return val._some.Var == Ord.Greater;
    241             } else {
    242                 val = self.Field1.PartialCmp(other.Field1);
    243 
    244                 if (val.IsNone) {
    245                     return false;
    246                 } else if (val._some.Var != Ord.Equivalent) {
    247                     return val._some.Var == Ord.Greater;
    248                 } else {
    249                     val = self.Field2.PartialCmp(other.Field2);
    250 
    251                     if (val.IsNone) {
    252                         return false;
    253                     } else if (val._some.Var != Ord.Equivalent) {
    254                         return val._some.Var == Ord.Greater;
    255                     } else {
    256                         val = self.Field3.PartialCmp(other.Field3);
    257                         return val.IsSome && val._some.Var == Ord.Greater;
    258                     }
    259                 }
    260             }
    261         }
    262         public static Unit Hash<TSelf, T0, THasher>(this TSelf self, ref THasher hasher) where T0: notnull, IHashable where THasher: notnull, IHasher where TSelf: notnull, IProduct<T0> => self.Field0.Hash(ref hasher);
    263         public static Unit Hash<TSelf, T0, T1, THasher>(this TSelf self, ref THasher hasher) where T0: notnull, IHashable where T1: notnull, IHashable where THasher: notnull, IHasher where TSelf: notnull, IProduct<T0, T1> {
    264 
    265             _ = self.Field0.Hash(ref hasher);
    266             return self.Field1.Hash(ref hasher);
    267         }
    268         public static Unit Hash<TSelf, T0, T1, T2, THasher>(this TSelf self, ref THasher hasher) where T0: notnull, IHashable where T1: notnull, IHashable where T2: notnull, IHashable where THasher: notnull, IHasher where TSelf: notnull, IProduct<T0, T1, T2> {
    269 
    270             _ = self.Field0.Hash(ref hasher);
    271             _ = self.Field1.Hash(ref hasher);
    272             return self.Field2.Hash(ref hasher);
    273         }
    274         public static Unit Hash<TSelf, T0, T1, T2, T3, THasher>(this TSelf self, ref THasher hasher) where T0: notnull, IHashable where T1: notnull, IHashable where T2: notnull, IHashable where T3: notnull, IHashable where THasher: notnull, IHasher where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    275 
    276             _ = self.Field0.Hash(ref hasher);
    277             _ = self.Field1.Hash(ref hasher);
    278             _ = self.Field2.Hash(ref hasher);
    279             return self.Field3.Hash(ref hasher);
    280         }
    281         public static string IntoString<TSelf, T0>(this TSelf self) where T0: notnull, IInto<string> where TSelf: notnull, IProduct<T0> => $"({self.Field0.Into()})";
    282         public static string IntoString<TSelf, T0, T1>(this TSelf self) where T0: notnull, IInto<string> where T1: notnull, IInto<string> where TSelf: notnull, IProduct<T0, T1> => $"({self.Field0.Into()}, {self.Field1.Into()})";
    283         public static string IntoString<TSelf, T0, T1, T2>(this TSelf self) where T0: notnull, IInto<string> where T1: notnull, IInto<string> where T2: notnull, IInto<string> where TSelf: notnull, IProduct<T0, T1, T2> => $"({self.Field0.Into()}, {self.Field1.Into()}, {self.Field2.Into()})";
    284         public static string IntoString<TSelf, T0, T1, T2, T3>(this TSelf self) where T0: notnull, IInto<string> where T1: notnull, IInto<string> where T2: notnull, IInto<string> where T3: notnull, IInto<string> where TSelf: notnull, IProduct<T0, T1, T2, T3> => $"({self.Field0.Into()}, {self.Field1.Into()}, {self.Field2.Into()}, {self.Field3.Into()})";
    285         public static bool Le<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 <= other.Field0;
    286         public static bool Le<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where TSelf: notnull, IProduct<T0, T1> {
    287 
    288             var val = self.Field0.PartialCmp(other.Field0);
    289 
    290             if (val.IsNone) {
    291                 return false;
    292             } else if (val._some.Var != Ord.Equivalent) {
    293                 return val._some.Var == Ord.Less;
    294             } else {
    295                 val = self.Field1.PartialCmp(other.Field1);
    296                 return val.IsSome && val._some.Var != Ord.Greater;
    297             }
    298         }
    299         public static bool Le<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> {
    300 
    301             var val = self.Field0.PartialCmp(other.Field0);
    302 
    303             if (val.IsNone) {
    304                 return false;
    305             } else if (val._some.Var != Ord.Equivalent) {
    306                 return val._some.Var == Ord.Less;
    307             } else {
    308                 val = self.Field1.PartialCmp(other.Field1);
    309 
    310                 if (val.IsNone) {
    311                     return false;
    312                 } else if (val._some.Var != Ord.Equivalent) {
    313                     return val._some.Var == Ord.Less;
    314                 } else {
    315                     val = self.Field2.PartialCmp(other.Field2);
    316                     return val.IsSome && val._some.Var != Ord.Greater;
    317                 }
    318             }
    319         }
    320         public static bool Le<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where T3: notnull, IPartialOrd<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    321 
    322             var val = self.Field0.PartialCmp(other.Field0);
    323 
    324             if (val.IsNone) {
    325                 return false;
    326             } else if (val._some.Var != Ord.Equivalent) {
    327                 return val._some.Var == Ord.Less;
    328             } else {
    329                 val = self.Field1.PartialCmp(other.Field1);
    330 
    331                 if (val.IsNone) {
    332                     return false;
    333                 } else if (val._some.Var != Ord.Equivalent) {
    334                     return val._some.Var == Ord.Less;
    335                 } else {
    336                     val = self.Field2.PartialCmp(other.Field2);
    337 
    338                     if (val.IsNone) {
    339                         return false;
    340                     } else if (val._some.Var != Ord.Equivalent) {
    341                         return val._some.Var == Ord.Less;
    342                     } else {
    343                         val = self.Field3.PartialCmp(other.Field3);
    344                         return val.IsSome && val._some.Var != Ord.Greater;
    345                     }
    346                 }
    347             }
    348         }
    349         public static bool Lt<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 < other.Field0;
    350         public static bool Lt<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where TSelf: notnull, IProduct<T0, T1> {
    351 
    352             var val = self.Field0.PartialCmp(other.Field0);
    353 
    354             if (val.IsNone) {
    355                 return false;
    356             } else if (val._some.Var != Ord.Equivalent) {
    357                 return val._some.Var == Ord.Less;
    358             } else {
    359                 val = self.Field1.PartialCmp(other.Field1);
    360                 return val.IsSome && val._some.Var == Ord.Less;
    361             }
    362         }
    363         public static bool Lt<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> {
    364 
    365             var val = self.Field0.PartialCmp(other.Field0);
    366 
    367             if (val.IsNone) {
    368                 return false;
    369             } else if (val._some.Var != Ord.Equivalent) {
    370                 return val._some.Var == Ord.Less;
    371             } else {
    372                 val = self.Field1.PartialCmp(other.Field1);
    373 
    374                 if (val.IsNone) {
    375                     return false;
    376                 } else if (val._some.Var != Ord.Equivalent) {
    377                     return val._some.Var == Ord.Less;
    378                 } else {
    379                     val = self.Field2.PartialCmp(other.Field2);
    380                     return val.IsSome && val._some.Var == Ord.Less;
    381                 }
    382             }
    383         }
    384         public static bool Lt<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where T3: notnull, IPartialOrd<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    385 
    386             var val = self.Field0.PartialCmp(other.Field0);
    387 
    388             if (val.IsNone) {
    389                 return false;
    390             } else if (val._some.Var != Ord.Equivalent) {
    391                 return val._some.Var == Ord.Less;
    392             } else {
    393                 val = self.Field1.PartialCmp(other.Field1);
    394 
    395                 if (val.IsNone) {
    396                     return false;
    397                 } else if (val._some.Var != Ord.Equivalent) {
    398                     return val._some.Var == Ord.Less;
    399                 } else {
    400                     val = self.Field2.PartialCmp(other.Field2);
    401 
    402                     if (val.IsNone) {
    403                         return false;
    404                     } else if (val._some.Var != Ord.Equivalent) {
    405                         return val._some.Var == Ord.Less;
    406                     } else {
    407                         val = self.Field3.PartialCmp(other.Field3);
    408                         return val.IsSome && val._some.Var == Ord.Less;
    409                     }
    410                 }
    411             }
    412         }
    413         public static bool Ne<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0 != other.Field0;
    414         public static bool Ne<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where TSelf: notnull, IProduct<T0, T1> => self.Field0 != other.Field0 || self.Field1 != other.Field1;
    415         public static bool Ne<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where T2: notnull, IPartialEq<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> => self.Field0 != other.Field0 || self.Field1 != other.Field1 || self.Field2 != other.Field2;
    416         public static bool Ne<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialEq<T0, T0> where T1: notnull, IPartialEq<T1, T1> where T2: notnull, IPartialEq<T2, T2> where T3: notnull, IPartialEq<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> => self.Field0 != other.Field0 || self.Field1 != other.Field1 || self.Field2 != other.Field2 || self.Field3 != other.Field3;
    417         public static Maybe<Ordering> PartialCmp<TSelf, T0>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where TSelf: notnull, IProduct<T0> => self.Field0.PartialCmp(other.Field0);
    418         public static Maybe<Ordering> PartialCmp<TSelf, T0, T1>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where TSelf: notnull, IProduct<T0, T1> {
    419 
    420             var val = self.Field0.PartialCmp(other.Field0);
    421 
    422             if (val.IsNone) {
    423                 return new Maybe<Ordering>();
    424             } else if (val._some.Var != Ord.Equivalent) {
    425                 return new(val._some);
    426             } else {
    427                 val = self.Field1.PartialCmp(other.Field1);
    428                 return val.IsNone ? new Maybe<Ordering>() : new(val._some);
    429             }
    430         }
    431         public static Maybe<Ordering> PartialCmp<TSelf, T0, T1, T2>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where TSelf: notnull, IProduct<T0, T1, T2> {
    432 
    433             var val = self.Field0.PartialCmp(other.Field0);
    434 
    435             if (val.IsNone) {
    436                 return new Maybe<Ordering>();
    437             } else if (val._some.Var != Ord.Equivalent) {
    438                 return new(val._some);
    439             } else {
    440                 val = self.Field1.PartialCmp(other.Field1);
    441 
    442                 if (val.IsNone) {
    443                     return new Maybe<Ordering>();
    444                 } else if (val._some.Var != Ord.Equivalent) {
    445                     return new(val._some);
    446                 } else {
    447                     val = self.Field2.PartialCmp(other.Field2);
    448                     return val.IsNone ? new Maybe<Ordering>() : new(val._some);
    449                 }
    450             }
    451         }
    452         public static Maybe<Ordering> PartialCmp<TSelf, T0, T1, T2, T3>(this TSelf self, TSelf other) where T0: notnull, IPartialOrd<T0, T0> where T1: notnull, IPartialOrd<T1, T1> where T2: notnull, IPartialOrd<T2, T2> where T3: notnull, IPartialOrd<T3, T3> where TSelf: notnull, IProduct<T0, T1, T2, T3> {
    453 
    454             var val = self.Field0.PartialCmp(other.Field0);
    455 
    456             if (val.IsNone) {
    457                 return new Maybe<Ordering>();
    458             } else if (val._some.Var != Ord.Equivalent) {
    459                 return new(val._some);
    460             } else {
    461                 val = self.Field1.PartialCmp(other.Field1);
    462 
    463                 if (val.IsNone) {
    464                     return new Maybe<Ordering>();
    465                 } else if (val._some.Var != Ord.Equivalent) {
    466                     return new(val._some);
    467                 } else {
    468                     val = self.Field2.PartialCmp(other.Field2);
    469 
    470                     if (val.IsNone) {
    471                         return new Maybe<Ordering>();
    472                     } else if (val._some.Var != Ord.Equivalent) {
    473                         return new(val._some);
    474                     } else {
    475                         val = self.Field3.PartialCmp(other.Field3);
    476                         return val.IsNone ? new Maybe<Ordering>() : new(val._some);
    477                     }
    478                 }
    479             }
    480         }
    481         #endregion
    482 
    483         #region Instance Functions
    484         #endregion
    485 
    486         #region Operators
    487         #endregion
    488 
    489         #region Types
    490         #endregion
    491     }
    492     public static class Slice {
    493 
    494         #region Type-level Constructors
    495         #endregion
    496 
    497         #region Instance Constructors
    498         #endregion
    499 
    500         #region Type-level Fields
    501         #endregion
    502 
    503         #region Instance Fields
    504         #endregion
    505 
    506         #region Type-level Properties
    507         #endregion
    508 
    509         #region Instance Properties
    510         #endregion
    511 
    512         #region Type-level Functions
    513         public static Ordering Cmp<T>(in this ReadOnlySpan<T> self, in ReadOnlySpan<T> other) where T: notnull, IOrd<T> {
    514 
    515             Ordering val;
    516 
    517             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    518                 val = self[i].Cmp(in other[i]);
    519                 if (val.Var != Ord.Equivalent) { return val; }
    520             }
    521             return self.Length.CompareTo(other.Length) switch {
    522                 < 0 => Less,
    523                 > 0 => Greater,
    524                 0 => Equivalent,
    525             };
    526         }
    527         public static Ordering Cmp<T>(in this Span<T> self, in Span<T> other) where T: notnull, IOrd<T> {
    528 
    529             Ordering val;
    530 
    531             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    532                 val = self[i].Cmp(in other[i]);
    533                 if (val.Var != Ord.Equivalent) { return val; }
    534             }
    535             return self.Length.CompareTo(other.Length) switch {
    536                 < 0 => Less,
    537                 > 0 => Greater,
    538                 0 => Equivalent,
    539             };
    540         }
    541         public static int CompareToComparable<T>(in this ReadOnlySpan<T> self, in ReadOnlySpan<T> other) where T: notnull, IComparable<T> {
    542 
    543             int val;
    544 
    545             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    546                 val = self[i].CompareTo(other[i]);
    547 
    548                 if (val != 0) {
    549                     return val;
    550                 }
    551             }
    552             return self.Length.CompareTo(other.Length);
    553         }
    554         public static int CompareToComparable<T>(in this Span<T> self, in Span<T> other) where T: notnull, IComparable<T> {
    555 
    556             int val;
    557 
    558             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    559                 val = self[i].CompareTo(other[i]);
    560 
    561                 if (val != 0) {
    562                     return val;
    563                 }
    564             }
    565             return self.Length.CompareTo(other.Length);
    566         }
    567         public static bool Eq<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialEq<T0, T1> where T1: notnull, IPartialEq<T1, T0> {
    568             
    569             if (self.Length != other.Length) { return false; }
    570 
    571             for (var i = 0; i < self.Length; i++) {
    572 
    573                 if (!(self[i] == other[i])) {
    574                     return false;
    575                 }
    576             }
    577             return true;
    578         }
    579         public static bool Eq<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialEq<T0, T1> where T1: notnull, IPartialEq<T1, T0> {
    580             
    581             if (self.Length != other.Length) { return false; }
    582 
    583             for (var i = 0; i < self.Length; i++) {
    584 
    585                 if (!(self[i] == other[i])) {
    586                     return false;
    587                 }
    588             }
    589             return true;
    590         }
    591         public static bool EqualsEquatable<T>(in this ReadOnlySpan<T> self, in ReadOnlySpan<T> other) where T: notnull, IEquatable<T> {
    592 
    593             if (self.Length != other.Length) { return false; }
    594 
    595             for (var i = 0; i < self.Length; i++) {
    596 
    597                 if (!self[i].Equals(other[i])) {
    598                     return false;
    599                 }
    600             }
    601             return true;
    602         }
    603         public static bool EqualsEquatable<T>(in this Span<T> self, in Span<T> other) where T: notnull, IEquatable<T> {
    604 
    605             if (self.Length != other.Length) { return false; }
    606 
    607             for (var i = 0; i < self.Length; i++) {
    608 
    609                 if (!self[i].Equals(other[i])) {
    610                     return false;
    611                 }
    612             }
    613             return true;
    614         }
    615         public static bool EqualsEquality<T>(in this ReadOnlySpan<T> self, in ReadOnlySpan<T> other) where T: notnull, IEquality<T> {
    616 
    617             if (self.Length != other.Length) { return false; }
    618             for (var i = 0; i < self.Length; i++) { if (!self[i].Equals(other[i])) { return false; } }
    619             return true;
    620         }
    621         public static bool EqualsEquality<T>(in this Span<T> self, in Span<T> other) where T: notnull, IEquality<T> {
    622 
    623             if (self.Length != other.Length) { return false; }
    624             for (var i = 0; i < self.Length; i++) { if (!self[i].Equals(other[i])) { return false; } }
    625             return true;
    626         }
    627         public static Maybe<T> First<T>(in this ReadOnlySpan<T> self) where T: notnull => self.Length == 0 ? Maybe<T>.None() : new(self[0]);
    628         public static Maybe<T> First<T>(in this Span<T> self) where T: notnull => self.Length == 0 ? Maybe<T>.None() : new(self[0]);
    629         public static bool Ge<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    630 
    631             Maybe<Ordering> val;
    632 
    633             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    634                 val = self[i].PartialCmp(in other[i]);
    635 
    636                 if (val.IsNone) {
    637                     return false;
    638                 } else if (val._some.Var != Ord.Equivalent) {
    639                     return val._some.Var == Ord.Greater;
    640                 }
    641             }
    642             return self.Length >= other.Length;
    643         }
    644         public static bool Ge<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    645 
    646             Maybe<Ordering> val;
    647 
    648             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    649                 val = self[i].PartialCmp(in other[i]);
    650 
    651                 if (val.IsNone) {
    652                     return false;
    653                 } else if (val._some.Var != Ord.Equivalent) {
    654                     return val._some.Var == Ord.Greater;
    655                 }
    656             }
    657             return self.Length >= other.Length;
    658         }
    659         public static Maybe<T> Get<T>(in this ReadOnlySpan<T> self, uint index) where T: notnull => index >= (uint)self.Length ? Maybe<T>.None() : new(self[(int)index]);
    660         public static Maybe<T> Get<T>(in this Span<T> self, uint index) where T: notnull => index >= (uint)self.Length ? Maybe<T>.None() : new(self[(int)index]);
    661         public static int GetHashCodeEquatable<T>(in this ReadOnlySpan<T> self) where T: notnull, IEquatable<T> {
    662 
    663             var hash = 0;
    664             for (var i = 0; i < self.Length; i++) { hash = HashCode.Combine(hash, self[i]); }
    665             return hash;
    666         }
    667         public static int GetHashCodeEquatable<T, THasher>(in this Span<T> self) where T: notnull, IEquatable<T> {
    668 
    669             var hash = 0;
    670             for (var i = 0; i < self.Length; i++) { hash = HashCode.Combine(hash, self[i]); }
    671             return hash;
    672         }
    673         public static bool Gt<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    674 
    675             Maybe<Ordering> val;
    676 
    677             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    678                 val = self[i].PartialCmp(in other[i]);
    679 
    680                 if (val.IsNone) {
    681                     return false;
    682                 } else if (val._some.Var != Ord.Equivalent) {
    683                     return val._some.Var == Ord.Greater;
    684                 }
    685             }
    686             return self.Length > other.Length;
    687         }
    688         public static bool Gt<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    689 
    690             Maybe<Ordering> val;
    691 
    692             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    693                 val = self[i].PartialCmp(in other[i]);
    694 
    695                 if (val.IsNone) {
    696                     return false;
    697                 } else if (val._some.Var != Ord.Equivalent) {
    698                     return val._some.Var == Ord.Greater;
    699                 }
    700             }
    701             return self.Length > other.Length;
    702         }
    703         public static Unit Hash<T, THasher>(in this ReadOnlySpan<T> self, ref THasher hasher) where T: notnull, IHashable where THasher: notnull, IHasher {
    704 
    705             for (var i = 0; i < self.Length; i++) {
    706                 _ = self[i].Hash(ref hasher);
    707             }
    708             return new Unit();
    709         }
    710         public static Unit Hash<T, THasher>(in this Span<T> self, ref THasher hasher) where T: notnull, IHashable where THasher: notnull, IHasher {
    711 
    712             for (var i = 0; i < self.Length; i++) {
    713                 _ = self[i].Hash(ref hasher);
    714             }
    715             return new Unit();
    716         }
    717         public static bool Le<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    718 
    719             Maybe<Ordering> val;
    720 
    721             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    722                 val = self[i].PartialCmp(in other[i]);
    723 
    724                 if (val.IsNone) {
    725                     return false;
    726                 } else if (val._some.Var != Ord.Equivalent) {
    727                     return val._some.Var == Ord.Less;
    728                 }
    729             }
    730             return self.Length <= other.Length;
    731         }
    732         public static bool Le<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    733 
    734             Maybe<Ordering> val;
    735 
    736             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    737                 val = self[i].PartialCmp(in other[i]);
    738 
    739                 if (val.IsNone) {
    740                     return false;
    741                 } else if (val._some.Var != Ord.Equivalent) {
    742                     return val._some.Var == Ord.Less;
    743                 }
    744             }
    745             return self.Length <= other.Length;
    746         }
    747         public static string LowerHex(this ReadOnlySpan<byte> self) {
    748 
    749             var sb = new StringBuilder("0x", (self.Length * 2) + 2);
    750             for (var i = 0; i < self.Length; i++) { sb = sb.Append(self[i].ToString("x2")); }
    751             return sb.ToString();
    752         }
    753         public static string LowerHex(this Span<byte> self) {
    754 
    755             var sb = new StringBuilder("0x", (self.Length * 2) + 2);
    756             for (var i = 0; i < self.Length; i++) { sb = sb.Append(self[i].ToString("x2")); }
    757             return sb.ToString();
    758         }
    759         public static bool Lt<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    760 
    761             Maybe<Ordering> val;
    762 
    763             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    764                 val = self[i].PartialCmp(in other[i]);
    765 
    766                 if (val.IsNone) {
    767                     return false;
    768                 } else if (val._some.Var != Ord.Equivalent) {
    769                     return val._some.Var == Ord.Less;
    770                 }
    771             }
    772             return self.Length < other.Length;
    773         }
    774         public static bool Lt<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    775 
    776             Maybe<Ordering> val;
    777 
    778             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    779                 val = self[i].PartialCmp(in other[i]);
    780 
    781                 if (val.IsNone) {
    782                     return false;
    783                 } else if (val._some.Var != Ord.Equivalent) {
    784                     return val._some.Var == Ord.Less;
    785                 }
    786             }
    787             return self.Length < other.Length;
    788         }
    789         public static bool Ne<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialEq<T0, T1> where T1: notnull, IPartialEq<T1, T0> {
    790 
    791             if (self.Length != other.Length) { return true; }
    792 
    793             for (var i = 0; i < self.Length; i++) {
    794 
    795                 if (self[i] != other[i]) {
    796                     return true;
    797                 }
    798             }
    799             return false;
    800         }
    801         public static bool Ne<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialEq<T0, T1> where T1: notnull, IPartialEq<T1, T0> {
    802 
    803             if (self.Length != other.Length) { return true; }
    804 
    805             for (var i = 0; i < self.Length; i++) {
    806 
    807                 if (self[i] != other[i]) {
    808                     return true;
    809                 }
    810             }
    811             return false;
    812         }
    813         public static Maybe<Ordering> PartialCmp<T0, T1>(in this ReadOnlySpan<T0> self, in ReadOnlySpan<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    814 
    815             Maybe<Ordering> val;
    816 
    817             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    818                 val = self[i].PartialCmp(in other[i]);
    819 
    820                 if (val.IsNone) {
    821                     return new Maybe<Ordering>();
    822                 } else if (val._some.Var != Ord.Equivalent) {
    823                     return new(val._some);
    824                 }
    825             }
    826             return self.Length.CompareTo(other.Length) switch {
    827                 < 0 => new Maybe<Ordering>(Less),
    828                 > 0 => new Maybe<Ordering>(Greater),
    829                 0 => new Maybe<Ordering>(Equivalent),
    830             };
    831         }
    832         public static Maybe<Ordering> PartialCmp<T0, T1>(in this Span<T0> self, in Span<T1> other) where T0: notnull, IPartialOrd<T0, T1> where T1: notnull, IPartialOrd<T1, T0> {
    833 
    834             Maybe<Ordering> val;
    835 
    836             for (var i = 0; i < Math.Min(self.Length, other.Length); i++) {
    837                 val = self[i].PartialCmp(in other[i]);
    838 
    839                 if (val.IsNone) {
    840                     return new Maybe<Ordering>();
    841                 } else if (val._some.Var != Ord.Equivalent) {
    842                     return new(val._some);
    843                 }
    844             }
    845             return self.Length.CompareTo(other.Length) switch {
    846                 < 0 => new Maybe<Ordering>(Less),
    847                 > 0 => new Maybe<Ordering>(Greater),
    848                 0 => new Maybe<Ordering>(Equivalent),
    849             };
    850         }
    851         internal static Unit RingSlices<T>(this ReadOnlySpan<T> self, uint head, uint tail, out ReadOnlySpan<T> v0, out ReadOnlySpan<T> v1) where T: notnull {
    852 
    853             var contiguous = tail <= head;
    854             if (contiguous) {
    855                 _ = self.SplitAt(uint.MinValue, out var empty, out var buf);
    856                 v0 = buf.slice(tail, head);
    857                 v1 = empty;
    858                 return new Unit();
    859             } else {
    860                 _ = self.SplitAt(tail, out var mid, out var right);
    861                 _ = mid.SplitAt(head, out var left, out var _);
    862                 v0 = right;
    863                 v1 = left;
    864                 return new Unit();
    865             }
    866         }
    867         internal static ReadOnlySpan<T> slice<T>(this ReadOnlySpan<T> self, uint from, uint to) where T: notnull => self[(int)from..(int)to];
    868         internal static Unit SplitAt<T>(this ReadOnlySpan<T> self, uint i, out ReadOnlySpan<T> v0, out ReadOnlySpan<T> v1) where T: notnull {
    869 
    870             v0 = self[0..(int)i];
    871             v1 = self[(int)i..];
    872             return new Unit();
    873         }
    874         internal static Unit RingSlices<T>(this Span<T> self, uint head, uint tail, out Span<T> v0, out Span<T> v1) where T: notnull {
    875 
    876             var contiguous = tail <= head;
    877             if (contiguous) {
    878                 _ = self.SplitAt(uint.MinValue, out var empty, out var buf);
    879                 v0 = buf.slice(tail, head);
    880                 v1 = empty;
    881                 return new Unit();
    882             } else {
    883                 _ = self.SplitAt(tail, out var mid, out var right);
    884                 _ = mid.SplitAt(head, out var left, out var _);
    885                 v0 = right;
    886                 v1 = left;
    887                 return new Unit();
    888             }
    889         }
    890         internal static Span<T> slice<T>(this Span<T> self, uint from, uint to) where T: notnull => self[(int)from..(int)to];
    891         internal static Unit SplitAt<T>(this Span<T> self, uint i, out Span<T> v0, out Span<T> v1) where T: notnull {
    892 
    893             v0 = self[0..(int)i];
    894             v1 = self[(int)i..];
    895             return new Unit();
    896         }
    897         public static Unit Swap<T>(this Span<T> self, uint a, uint b) where T: notnull {
    898 
    899             (self[(int)a], self[(int)b]) = (self[(int)b], self[(int)a]);
    900             return new Unit();
    901         }
    902         public static string ToArrayString<T>(this ReadOnlySpan<T> self) where T: notnull {
    903 
    904             if (self.Length == 0) { return "{}"; }
    905             var sb = new StringBuilder("{ ", self.Length * 16);
    906             for (var i = 0; i < self.Length; i++) { sb = sb.Append($"{self[i].ToString()}, "); }
    907             return sb.Remove(sb.Length - 2, 2).Append(" }").ToString();
    908         }
    909         public static string ToArrayString<T>(this Span<T> self) where T: notnull {
    910 
    911             if (self.Length == 0) { return "{}"; }
    912             var sb = new StringBuilder("{ ", self.Length * 16);
    913             for (var i = 0; i < self.Length; i++) { sb = sb.Append($"{self[i].ToString()}, "); }
    914             return sb.Remove(sb.Length - 2, 2).Append(" }").ToString();
    915         }
    916         public static string UpperHex(this ReadOnlySpan<byte> self) {
    917 
    918             var sb = new StringBuilder("0x", (self.Length * 2) + 2);
    919             for (var i = 0; i < self.Length; i++) { sb = sb.Append(self[i].ToString("X2")); }
    920             return sb.ToString();
    921         }
    922         public static string UpperHex(this Span<byte> self) {
    923 
    924             var sb = new StringBuilder("0x", (self.Length * 2) + 2);
    925             for (var i = 0; i < self.Length; i++) { sb = sb.Append(self[i].ToString("X2")); }
    926             return sb.ToString();
    927         }
    928         #endregion
    929 
    930         #region Instance Functions
    931         #endregion
    932 
    933         #region Operators
    934         #endregion
    935 
    936         #region Types
    937         #endregion
    938     }
    939     #endregion
    940 
    941     #region Namespaces
    942     #endregion
    943 }
    944 #endregion