Browse Source

Remove last unsafes (#354)

Jack May 5 years ago
parent
commit
c3bb55e88a
2 changed files with 3 additions and 25 deletions
  1. 1 0
      program/src/lib.rs
  2. 2 25
      program/src/option.rs

+ 1 - 0
program/src/lib.rs

@@ -1,4 +1,5 @@
 #![deny(missing_docs)]
+#![forbid(unsafe_code)]
 
 //! An ERC20-like Token program for the Solana blockchain
 

+ 2 - 25
program/src/option.rs

@@ -4,9 +4,8 @@
 //! This implementation mostly matches `std::option` except iterators since the iteration
 //! trait requires returning `std::option::Option`
 
-use std::pin::Pin;
 use std::{
-    convert, hint, mem,
+    convert, mem,
     ops::{Deref, DerefMut},
 };
 
@@ -151,28 +150,6 @@ impl<T> COption<T> {
         }
     }
 
-    /// Converts from [`Pin`]`<&COption<T>>` to `COption<`[`Pin`]`<&T>>`.
-    ///
-    /// [`Pin`]: ../pin/struct.Pin.html
-    #[inline]
-    #[allow(clippy::wrong_self_convention)]
-    pub fn as_pin_ref(self: Pin<&Self>) -> COption<Pin<&T>> {
-        unsafe { Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x)) }
-    }
-
-    /// Converts from [`Pin`]`<&mut COption<T>>` to `COption<`[`Pin`]`<&mut T>>`.
-    ///
-    /// [`Pin`]: ../pin/struct.Pin.html
-    #[inline]
-    #[allow(clippy::wrong_self_convention)]
-    pub fn as_pin_mut(self: Pin<&mut Self>) -> COption<Pin<&mut T>> {
-        unsafe {
-            Pin::get_unchecked_mut(self)
-                .as_mut()
-                .map(|x| Pin::new_unchecked(x))
-        }
-    }
-
     /////////////////////////////////////////////////////////////////////////
     // Getting to contained values
     /////////////////////////////////////////////////////////////////////////
@@ -645,7 +622,7 @@ impl<T> COption<T> {
 
         match *self {
             COption::Some(ref mut v) => v,
-            COption::None => unsafe { hint::unreachable_unchecked() },
+            COption::None => unreachable!(),
         }
     }