Esempio n. 1
0
 def remove(self, idx: int) -> Option[u]:
     try:
         _ = self[idx]
         del self[idx]
         return some(_)
     except IndexError:
         return none
Esempio n. 2
0
 def rsplit_once(self, u: u) -> Option[(str, str)]:
     opt_idx = self.rchar_index(u)
     if opt_idx is none: return none
     first, last = self.split_at(opt_idx.unwrap())
     last.remove(0)
     return some((str(first), str(last)))
Esempio n. 3
0
 def rchar_index(self, u: u) -> Option[int]:
     try:
         return some(len(self) - 1 - self[::-1].index(u))
     except ValueError:
         return none
Esempio n. 4
0
 def char_index(self, u: u) -> Option[int]:
     try:
         return some(self.index(u))
     except ValueError:
         return none
Esempio n. 5
0
 def pop(self) -> Option[u]:
     try:
         return some(super().pop())
     except IndexError:
         return none