More minor cleanup
This commit is contained in:
parent
c776534ad4
commit
d5a9a239f6
|
|
@ -142,31 +142,28 @@ impl<T: Stackable> Ref<Stack<T>> {
|
||||||
/// Returns a reference to the element at the given index in the
|
/// Returns a reference to the element at the given index in the
|
||||||
/// stack or `None` if the index is out of bounds
|
/// stack or `None` if the index is out of bounds
|
||||||
pub fn get(&self, idx: usize) -> Option<&Ref<T>> {
|
pub fn get(&self, idx: usize) -> Option<&Ref<T>> {
|
||||||
|
unsafe {
|
||||||
if idx >= self.len() {
|
if idx >= self.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
Some(Ref::from_ptr(self._get(idx)))
|
||||||
let r = Ref::from_ptr(self._get(idx));
|
|
||||||
|
|
||||||
Some(r)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a mutable reference to the element at the given index in the
|
/// Returns a mutable reference to the element at the given index in the
|
||||||
/// stack or `None` if the index is out of bounds
|
/// stack or `None` if the index is out of bounds
|
||||||
pub fn get_mut(&mut self, idx: usize) -> Option<&mut Ref<T>> {
|
pub fn get_mut(&mut self, idx: usize) -> Option<&mut Ref<T>> {
|
||||||
|
unsafe {
|
||||||
if idx >= self.len() {
|
if idx >= self.len() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe {
|
|
||||||
Some(Ref::from_ptr_mut(self._get(idx)))
|
Some(Ref::from_ptr_mut(self._get(idx)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn _get(&self, idx: usize) -> *mut T::CType {
|
unsafe fn _get(&self, idx: usize) -> *mut T::CType {
|
||||||
assert!(idx <= c_int::max_value() as usize);
|
|
||||||
OPENSSL_sk_value(self.as_stack(), idx as c_int) as *mut _
|
OPENSSL_sk_value(self.as_stack(), idx as c_int) as *mut _
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue