FnMut -> FnOnce, update docs

This commit is contained in:
Jonas Schievink 2016-06-26 19:44:53 +02:00
parent 351bc569a4
commit f24ab26936
3 changed files with 7 additions and 3 deletions

View File

@ -103,9 +103,11 @@ impl PKey {
///
/// The callback will be passed the password buffer and should return the number of characters
/// placed into the buffer.
///
/// Requires the `catch_unwind` feature.
#[cfg(feature = "catch_unwind")]
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> Result<PKey, SslError>
where R: Read, F: FnMut(&mut [c_char]) -> usize
where R: Read, F: FnOnce(&mut [c_char]) -> usize
{
let mut cb = CallbackState::new(pass_cb);

View File

@ -82,9 +82,11 @@ impl RSA {
}
/// Reads an RSA private key from PEM formatted data and supplies a password callback.
///
/// Requires the `catch_unwind` feature.
#[cfg(feature = "catch_unwind")]
pub fn private_key_from_pem_cb<R, F>(reader: &mut R, pass_cb: F) -> Result<RSA, SslError>
where R: Read, F: FnMut(&mut [c_char]) -> usize
where R: Read, F: FnOnce(&mut [c_char]) -> usize
{
let mut cb = CallbackState::new(pass_cb);

View File

@ -41,7 +41,7 @@ pub extern "C" fn invoke_passwd_cb<F>(buf: *mut c_char,
_rwflag: c_int,
cb_state: *mut c_void)
-> c_int
where F: FnMut(&mut [i8]) -> usize {
where F: FnOnce(&mut [i8]) -> usize {
let result = panic::catch_unwind(|| {
// build a `i8` slice to pass to the user callback
let pass_slice = unsafe { slice::from_raw_parts_mut(buf, size as usize) };