Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 64a9e15

Browse files
authored
Remove last unsafes (#354)
1 parent b4a3674 commit 64a9e15

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

token/program/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#![deny(missing_docs)]
2+
#![forbid(unsafe_code)]
23

34
//! An ERC20-like Token program for the Solana blockchain
45

token/program/src/option.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
//! This implementation mostly matches `std::option` except iterators since the iteration
55
//! trait requires returning `std::option::Option`
66
7-
use std::pin::Pin;
87
use std::{
9-
convert, hint, mem,
8+
convert, mem,
109
ops::{Deref, DerefMut},
1110
};
1211

@@ -151,28 +150,6 @@ impl<T> COption<T> {
151150
}
152151
}
153152

154-
/// Converts from [`Pin`]`<&COption<T>>` to `COption<`[`Pin`]`<&T>>`.
155-
///
156-
/// [`Pin`]: ../pin/struct.Pin.html
157-
#[inline]
158-
#[allow(clippy::wrong_self_convention)]
159-
pub fn as_pin_ref(self: Pin<&Self>) -> COption<Pin<&T>> {
160-
unsafe { Pin::get_ref(self).as_ref().map(|x| Pin::new_unchecked(x)) }
161-
}
162-
163-
/// Converts from [`Pin`]`<&mut COption<T>>` to `COption<`[`Pin`]`<&mut T>>`.
164-
///
165-
/// [`Pin`]: ../pin/struct.Pin.html
166-
#[inline]
167-
#[allow(clippy::wrong_self_convention)]
168-
pub fn as_pin_mut(self: Pin<&mut Self>) -> COption<Pin<&mut T>> {
169-
unsafe {
170-
Pin::get_unchecked_mut(self)
171-
.as_mut()
172-
.map(|x| Pin::new_unchecked(x))
173-
}
174-
}
175-
176153
/////////////////////////////////////////////////////////////////////////
177154
// Getting to contained values
178155
/////////////////////////////////////////////////////////////////////////
@@ -645,7 +622,7 @@ impl<T> COption<T> {
645622

646623
match *self {
647624
COption::Some(ref mut v) => v,
648-
COption::None => unsafe { hint::unreachable_unchecked() },
625+
COption::None => unreachable!(),
649626
}
650627
}
651628

0 commit comments

Comments
 (0)