Skip to content

Commit

Permalink
Use 3rd person tense for function docs
Browse files Browse the repository at this point in the history
As is typical in the Rust ecosystem use the third person tense when
documenting functions. E.g.,

```
/// Creates a new Foo.
```
As opposed to

```
/// Create a new Foo.
```
  • Loading branch information
tcharding committed Feb 9, 2022
1 parent c3be285 commit d25431c
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/ecdh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,35 +54,35 @@ impl_from_array_len!(SharedSecret, 256, (16 20 28 32 48 64 96 128 256));

impl SharedSecret {

/// Create an empty SharedSecret
/// Creates an empty `SharedSecret`.
pub(crate) fn empty() -> SharedSecret {
SharedSecret {
data: [0u8; 256],
len: 0,
}
}

/// Get a pointer to the underlying data with the specified capacity.
/// Gets a pointer to the underlying data with the specified capacity.
pub(crate) fn get_data_mut_ptr(&mut self) -> *mut u8 {
self.data.as_mut_ptr()
}

/// Get the capacity of the underlying data buffer.
/// Gets the capacity of the underlying data buffer.
pub fn capacity(&self) -> usize {
self.data.len()
}

/// Get the len of the used data.
/// Gets the len of the used data.
pub fn len(&self) -> usize {
self.len
}

/// True if the underlying data buffer is empty.
/// Returns true if the underlying data buffer is empty.
pub fn is_empty(&self) -> bool {
self.data.is_empty()
}

/// Set the length of the object.
/// Sets the length of the object.
pub(crate) fn set_len(&mut self, len: usize) {
debug_assert!(len <= self.data.len());
self.len = len;
Expand Down Expand Up @@ -116,7 +116,7 @@ unsafe extern "C" fn c_callback(output: *mut c_uchar, x: *const c_uchar, y: *con
}

impl SharedSecret {
/// Creates a new shared secret from a pubkey and secret key
/// Creates a new shared secret from a pubkey and secret key.
#[inline]
pub fn new(point: &PublicKey, scalar: &SecretKey) -> SharedSecret {
let mut ss = SharedSecret::empty();
Expand All @@ -138,7 +138,7 @@ impl SharedSecret {
}


/// Creates a new shared secret from a pubkey and secret key with applied custom hash function
/// Creates a new shared secret from a pubkey and secret key with applied custom hash function.
/// The custom hash function must be in the form of `fn(x: [u8;32], y: [u8;32]) -> SharedSecret`
/// `SharedSecret` can be easily created via the `From` impl from arrays.
/// # Examples
Expand Down

0 comments on commit d25431c

Please sign in to comment.