Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
heapless
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Per Lindgren
heapless
Commits
f515ed9e
Commit
f515ed9e
authored
8 years ago
by
Jorge Aparicio
Browse files
Options
Downloads
Patches
Plain Diff
v0.1.0
parent
2d8ff5b0
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
CHANGELOG.md
+14
-0
14 additions, 0 deletions
CHANGELOG.md
Cargo.toml
+7
-1
7 additions, 1 deletion
Cargo.toml
README.md
+8
-1
8 additions, 1 deletion
README.md
src/lib.rs
+31
-15
31 additions, 15 deletions
src/lib.rs
with
60 additions
and
17 deletions
CHANGELOG.md
0 → 100644
+
14
−
0
View file @
f515ed9e
# Change Log
All notable changes to this project will be documented in this file.
The format is based on
[
Keep a Changelog
](
http://keepachangelog.com/
)
and this project adheres to
[
Semantic Versioning
](
http://semver.org/
)
.
## [Unreleased]
## [v0.1.0] - 2017-04-27
-
Initial release
[
Unreleased
]:
https://github.com/japaric/heapless/compare/v0.1.0...HEAD
This diff is collapsed.
Click to expand it.
Cargo.toml
+
7
−
1
View file @
f515ed9e
[package]
[package]
authors
=
[
"Jorge Aparicio <jorge@japaric.io>"
]
categories
=
[
"data-structures"
,
"no-std"
]
description
=
"`static` friendly data structures that don't require dynamic memory allocation"
documentation
=
"https://docs.rs/heapless"
keywords
=
[
"static"
,
"no-heap"
]
license
=
"MIT OR Apache-2.0"
name
=
"heapless"
name
=
"heapless"
repository
=
"https://github.com/japaric/heapless"
version
=
"0.1.0"
version
=
"0.1.0"
authors
=
[
"Jorge Aparicio <japaricious@gmail.com>"
]
[dependencies]
[dependencies]
This diff is collapsed.
Click to expand it.
README.md
+
8
−
1
View file @
f515ed9e
[

](https://crates.io/crates/heapless)
[

](https://crates.io/crates/heapless)
# `heapless`
# `heapless`
> Heapless, `static` friendly data structures
> `static` friendly data structures that don't require dynamic memory allocation
# [Documentation](https://docs.rs/heapless)
# [Change log](CHANGELOG.md)
# License
# License
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
31
−
15
View file @
f515ed9e
//! Heapless, `static` friendly data structures
//! `static` friendly data structures that don't require dynamic memory
//! allocation
#![deny(missing_docs)]
#![deny(missing_docs)]
#![deny(warnings)]
#![deny(warnings)]
...
@@ -11,8 +12,9 @@ use core::slice;
...
@@ -11,8 +12,9 @@ use core::slice;
/// A circular buffer
/// A circular buffer
pub
struct
CircularBuffer
<
T
,
A
>
pub
struct
CircularBuffer
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
_marker
:
PhantomData
<
[
T
]
>
,
_marker
:
PhantomData
<
[
T
]
>
,
array
:
A
,
array
:
A
,
...
@@ -21,8 +23,9 @@ pub struct CircularBuffer<T, A>
...
@@ -21,8 +23,9 @@ pub struct CircularBuffer<T, A>
}
}
impl
<
T
,
A
>
CircularBuffer
<
T
,
A
>
impl
<
T
,
A
>
CircularBuffer
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
/// Creates a new empty circular buffer using `array` as backup storage
/// Creates a new empty circular buffer using `array` as backup storage
pub
const
fn
new
(
array
:
A
)
->
Self
{
pub
const
fn
new
(
array
:
A
)
->
Self
{
...
@@ -55,8 +58,9 @@ impl<T, A> CircularBuffer<T, A>
...
@@ -55,8 +58,9 @@ impl<T, A> CircularBuffer<T, A>
}
}
impl
<
T
,
A
>
Deref
for
CircularBuffer
<
T
,
A
>
impl
<
T
,
A
>
Deref
for
CircularBuffer
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
type
Target
=
[
T
];
type
Target
=
[
T
];
...
@@ -73,8 +77,9 @@ impl<T, A> Deref for CircularBuffer<T, A>
...
@@ -73,8 +77,9 @@ impl<T, A> Deref for CircularBuffer<T, A>
/// A continuous, growable array type
/// A continuous, growable array type
pub
struct
Vec
<
T
,
A
>
pub
struct
Vec
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
_marker
:
PhantomData
<
[
T
]
>
,
_marker
:
PhantomData
<
[
T
]
>
,
array
:
A
,
array
:
A
,
...
@@ -82,8 +87,9 @@ pub struct Vec<T, A>
...
@@ -82,8 +87,9 @@ pub struct Vec<T, A>
}
}
impl
<
T
,
A
>
Vec
<
T
,
A
>
impl
<
T
,
A
>
Vec
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
/// Creates a new vector using `array` as the backup storage
/// Creates a new vector using `array` as the backup storage
pub
const
fn
new
(
array
:
A
)
->
Self
{
pub
const
fn
new
(
array
:
A
)
->
Self
{
...
@@ -99,6 +105,11 @@ impl<T, A> Vec<T, A>
...
@@ -99,6 +105,11 @@ impl<T, A> Vec<T, A>
self
.array
.as_ref
()
.len
()
self
.array
.as_ref
()
.len
()
}
}
/// Clears the vector, removing all values
pub
fn
clear
(
&
mut
self
)
{
self
.len
=
0
;
}
/// Removes the last element from this vector and returns it, or `None` if
/// Removes the last element from this vector and returns it, or `None` if
/// it's empty
/// it's empty
pub
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
pub
fn
pop
(
&
mut
self
)
->
Option
<
T
>
{
...
@@ -107,8 +118,12 @@ impl<T, A> Vec<T, A>
...
@@ -107,8 +118,12 @@ impl<T, A> Vec<T, A>
}
else
{
}
else
{
self
.len
-=
1
;
self
.len
-=
1
;
unsafe
{
unsafe
{
Some
(
*
self
.array
.as_mut
()
.as_mut_ptr
()
.offset
(
self
.len
as
Some
(
isize
))
*
self
.array
.as_mut
()
.as_mut_ptr
()
.offset
(
self
.len
as
isize
),
)
}
}
}
}
}
}
...
@@ -132,8 +147,9 @@ impl<T, A> Vec<T, A>
...
@@ -132,8 +147,9 @@ impl<T, A> Vec<T, A>
}
}
impl
<
T
,
A
>
Deref
for
Vec
<
T
,
A
>
impl
<
T
,
A
>
Deref
for
Vec
<
T
,
A
>
where
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
where
T
:
Copy
A
:
AsMut
<
[
T
]
>
+
AsRef
<
[
T
]
>
,
T
:
Copy
,
{
{
type
Target
=
[
T
];
type
Target
=
[
T
];
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment