Skip to content

Commit

Permalink
readme style touchups
Browse files Browse the repository at this point in the history
  • Loading branch information
Moth-Tolias committed Feb 5, 2022
1 parent 68f1e90 commit e3e903c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,18 @@ in addition to these, [the range interface](https://dlang.org/spec/statement.htm
```d
void main() @safe @nogc nothrow
{
RingBuffer!(int, 5) buff; // non-power-of-two lengths are supported, though powers of two will be faster
RingBuffer!(int, 5) buff;
// non-power-of-two lengths are supported, though powers of two will be faster
buff.push(69);
buff ~= 420; //equivilent to the push syntax
buff ~= 420; // equivilent to the push syntax
assert(buff.shift == 69);
assert(buff.shift == 420);
import std.array : staticArray;
import std.range : iota;
immutable int[5] temp = staticArray!(iota(5));
buff.push(temp); //multiple items may be pushed in a single call
buff.push(temp); // multiple items may be pushed in a single call
assert(buff.length == 5);
assert(buff.capacity == 0);
Expand Down
7 changes: 4 additions & 3 deletions source/ringbuffer.d
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,18 @@ struct RingBuffer(DataType, size_t maxLength)
/// example
@safe @nogc nothrow unittest
{
RingBuffer!(int, 5) buff; // non-power-of-two lengths are supported, though powers of two will be faster
RingBuffer!(int, 5) buff;
// non-power-of-two lengths are supported, though powers of two will be faster
buff.push(69);
buff ~= 420; //equivilent to the push syntax
buff ~= 420; // equivilent to the push syntax
assert(buff.shift == 69);
assert(buff.shift == 420);

import std.array : staticArray;
import std.range : iota;
immutable int[5] temp = staticArray!(iota(5));

buff.push(temp); //multiple items may be pushed in a single call
buff.push(temp); // multiple items may be pushed in a single call

assert(buff.length == 5);
assert(buff.capacity == 0);
Expand Down

0 comments on commit e3e903c

Please sign in to comment.