File tree 3 files changed +17
-3
lines changed
3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 1
1
sudo : required
2
2
language : rust
3
3
rust :
4
- - stable
4
+ - nightly
5
5
env :
6
6
- secure : " TLRXkqd76FJwSAFOD8kZbieRzWpq6+RA/WrbqLGt9RRL3l65TUEwyDxYoUy5Jscj4bY5XsNPE6CfWggp2SMDcV1C/FNf4nVDTPieCwRluKVHDKpIcoloSVTKihyd6W0P0z9vWNHT7/eYPW+rL8ty2pbFeFJDFJXb1WSIdNcdZvtNHOk8HNKIA/Wiha8/8sHN0EA+EVOIJ3FPYxyQ1NVEYfdQb227LE0UOyTBxU7jke2e/st6GiUl0IPqZy0H38qP5pHismyqsbzlNMsEQqFZrwXE1Zvx3928sD5PBoBfYPsLS3AOz7/nWi/txI3tUm1nlxVzSRF3ZNT5pBmAJof1pBe6+is6C2bxhgTwoTDJBfc2I7fy60dPg3fl9DJWLROBwAaf5Ww2tzuwf0YM3CMSTdI01Y6/RL2n/JBg1h/jRLjZaiqi2rANvBG7iMStVeebJtXkGI0pUpNxTSLBYXBgU+YHwd3rSTXVC4q7Z45q4lsBJohTAWwV29ohz3a97yP+tCfl4KD2QXorV75Vk8A6pl38j1e35xSdWRy3tJp7LFoBqp1g9mz+v+PjZ+8CZ2alPbdp1X5O6Rc6xl1aK76Aw6b/Rz9QGiatEh22FP6EZtMoXhr6oXX+c1B+yqVHrHnPaCUVRfxk2ieg050U5AolXHA9/mxyBbFxzE0wLE3LDe4="
7
7
after_script :
8
8
- |
9
9
if [ "${TRAVIS_BRANCH}" = "master" -a -n "${GH_TOKEN}" ]; then
10
- cargo doc
10
+ cargo doc --features=const_fn
11
11
git clone https://github.com/davisp/ghp-import
12
12
./ghp-import/ghp_import.py -n target/doc
13
13
git push -fq https://${GH_TOKEN}@github.com/${TRAVIS_REPO_SLUG}.git gh-pages
Original file line number Diff line number Diff line change @@ -8,3 +8,6 @@ repository = "https://github.com/whitequark/rust-log_buffer"
8
8
homepage = " https://github.com/whitequark/rust-log_buffer"
9
9
documentation = " https://whitequark.github.io/rust-log_buffer/log_buffer"
10
10
description = " A zero-allocation ring buffer for storing text logs"
11
+
12
+ [features ]
13
+ const_fn = []
Original file line number Diff line number Diff line change 40
40
//! ```
41
41
42
42
#![ no_std]
43
+ #![ cfg_attr( feature = "const_fn" , feature( const_fn) ) ]
43
44
44
45
/// A ring buffer that stores UTF-8 text.
45
46
///
@@ -52,7 +53,7 @@ pub struct LogBuffer<T: AsMut<[u8]>> {
52
53
}
53
54
54
55
impl < T : AsMut < [ u8 ] > > LogBuffer < T > {
55
- /// Creates a new ring buffer, backed by the slice `storage`.
56
+ /// Creates a new ring buffer, backed by `storage`.
56
57
///
57
58
/// The buffer is cleared after creation.
58
59
pub fn new ( storage : T ) -> LogBuffer < T > {
@@ -61,6 +62,16 @@ impl<T: AsMut<[u8]>> LogBuffer<T> {
61
62
buffer
62
63
}
63
64
65
+ /// Creates a new ring buffer, backed by `storage`.
66
+ ///
67
+ /// The buffer is *not* cleared after creation, and contains whatever is in `storage`.
68
+ /// The `clear()` method should be called before use.
69
+ /// However, this function can be used in a static initializer.
70
+ #[ cfg( feature = "const_fn" ) ]
71
+ pub const fn uninitialized ( storage : T ) -> LogBuffer < T > {
72
+ LogBuffer { buffer : storage, position : 0 }
73
+ }
74
+
64
75
/// Clears the buffer.
65
76
///
66
77
/// Only the text written after clearing will be read out by a future extraction.
You can’t perform that action at this time.
0 commit comments