Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a const new associated function to ram_storage!'s output #87

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ pub struct Ancestors<'a> {
path: &'a str,
}

impl<'a> Iterator for Ancestors<'a> {
impl Iterator for Ancestors<'_> {
type Item = PathBuf;
fn next(&mut self) -> Option<PathBuf> {
if self.path.is_empty() {
Expand Down Expand Up @@ -118,7 +118,7 @@ impl<'a> Iterator for Ancestors<'a> {
}
}

impl<'a> FusedIterator for Ancestors<'a> {}
impl FusedIterator for Ancestors<'_> {}

/// Iterator over the components of a Path
///
Expand All @@ -127,7 +127,7 @@ pub struct Iter<'a> {
path: &'a str,
}

impl<'a> Iterator for Iter<'a> {
impl Iterator for Iter<'_> {
type Item = PathBuf;
fn next(&mut self) -> Option<PathBuf> {
if self.path.is_empty() {
Expand Down
7 changes: 3 additions & 4 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,6 @@ impl<'a, 'b, Storage: driver::Storage> File<'a, 'b, Storage> {
///
/// It is equivalent to OpenOptions::new() but allows you to write more readable code.
/// This also avoids the need to import OpenOptions`.

pub fn with_options() -> OpenOptions {
OpenOptions::new()
}
Expand Down Expand Up @@ -936,7 +935,7 @@ pub struct ReadDir<'a, 'b, S: driver::Storage> {
path: &'b Path,
}

impl<'a, 'b, S: driver::Storage> Iterator for ReadDir<'a, 'b, S> {
impl<S: driver::Storage> Iterator for ReadDir<'_, '_, S> {
type Item = Result<DirEntry>;

// remove this allowance again, once path overflow is properly handled
Expand Down Expand Up @@ -972,9 +971,9 @@ impl<'a, 'b, S: driver::Storage> Iterator for ReadDir<'a, 'b, S> {
}
}

impl<'a, 'b, S: driver::Storage> ReadDir<'a, 'b, S> {
impl<'a, S: driver::Storage> ReadDir<'a, '_, S> {
// Safety-hatch to experiment with missing parts of API
pub unsafe fn borrow_filesystem<'c>(&'c mut self) -> &'c Filesystem<'a, S> {
pub unsafe fn borrow_filesystem<'b>(&'b mut self) -> &'b Filesystem<'a, S> {
self.fs
}
}
Expand Down
12 changes: 9 additions & 3 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,20 @@ macro_rules! ram_storage { (
buf: [u8; $block_size * $block_count],
}

impl Default for $Backend {
fn default() -> Self {
$Backend {
impl $Backend {
pub const fn new() -> Self {
Self {
buf: [$erase_value; $block_size * $block_count],
}
}
}

impl Default for $Backend {
fn default() -> Self {
Self::new()
}
}

pub struct $Name<'backend> {
backend: &'backend mut $Backend,
}
Expand Down
Loading