mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-02 14:54:30 +00:00
Fix Default
impl
This commit is contained in:
parent
4e9bedc6fa
commit
d85e455f3b
@ -13,7 +13,7 @@ use core::{
|
||||
/// A fixed capacity [`CString`](https://doc.rust-lang.org/std/ffi/struct.CString.html).
|
||||
///
|
||||
/// It stores up to `N - 1` non-nul characters with a trailing nul terminator.
|
||||
#[derive(Clone, Default, Hash)]
|
||||
#[derive(Clone, Hash)]
|
||||
pub struct CString<const N: usize> {
|
||||
inner: Vec<u8, N>,
|
||||
}
|
||||
@ -273,6 +273,13 @@ impl<const N: usize> CString<N> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> Default for CString<N> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl<const N: usize> Borrow<CStr> for CString<N> {
|
||||
#[inline]
|
||||
fn borrow(&self) -> &CStr {
|
||||
@ -445,6 +452,10 @@ mod tests {
|
||||
Some(INITIAL_BYTES.len() + 5)
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn default() {
|
||||
assert_eq!(CString::<1>::default().as_c_str(), <&CStr>::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn deref() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user