Skip to content

Commit 727116e

Browse files
committed
chore: update to Noir 0.38.0
1 parent fa8c058 commit 727116e

File tree

8 files changed

+100
-191
lines changed

8 files changed

+100
-191
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
toolchain: [0.35.0, 0.36.0]
19+
toolchain: [0.38.0]
2020
steps:
2121
- name: Checkout sources
2222
uses: actions/checkout@v4
@@ -38,7 +38,7 @@ jobs:
3838
- name: Install Nargo
3939
uses: noir-lang/[email protected]
4040
with:
41-
toolchain: 0.36.0
41+
toolchain: 0.38.0
4242

4343
- name: Run formatter
4444
run: nargo fmt --check

Nargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
name = "nodash"
33
type = "lib"
44
authors = ["Oleh Misarosh <[email protected]>"]
5-
compiler_version = ">=0.30.0"
5+
compiler_version = ">=0.38.0"
66

77
[dependencies]

README.md

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,10 @@ Put this into your Nargo.toml.
99
If you are using Noir:
1010

1111
```toml
12-
nodash = { git = "https://github.com/olehmisar/nodash/", tag = "v0.36.0" }
12+
nodash = { git = "https://github.com/olehmisar/nodash/", tag = "v0.38.0" }
1313
```
1414

15-
The version of nodash matches the version of Noir. The patch version may be different if a bugfix or a new feature is added for the same version of Noir. E.g., [email protected] and [email protected] are compatible with [email protected].
16-
17-
---
18-
19-
If you are using Aztec:
20-
21-
```toml
22-
nodash = { git = "https://github.com/olehmisar/nodash/", tag = "aztec-v0.57.0" }
23-
```
24-
25-
The version of nodash matches the version of Aztec. E.g., [email protected] is compatible with [email protected].
15+
The version of nodash matches the version of Noir. The patch version may be different if a bugfix or a new feature is added for the same version of Noir. E.g., [email protected] and [email protected] are compatible with [email protected].
2616

2717
## Docs
2818

@@ -98,14 +88,14 @@ assert(str_to_u64("02345678912345678912") == 02345678912345678912);
9888

9989
### `ArrayExtensions`
10090

101-
#### `slice`
91+
#### `slice<L>(start: u32) -> [T; L]`
10292

103-
Returns a slice of the array.
93+
Returns a slice of the array, starting at `start` and ending at `start + L`. Panics if `start + L` is out of bounds.
10494

10595
```rs
10696
use nodash::ArrayExtensions;
10797

108-
assert([1, 2, 3, 4, 5].slice::<3>(1, 4) == [2, 3, 4]);
98+
assert([1, 2, 3, 4, 5].slice::<3>(1) == [2, 3, 4]);
10999
```
110100

111101
#### `concat`

src/array.nr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
impl<T, let N: u32> crate::ArrayExtensions<T, N> for [T; N] {
2-
fn slice<let M: u32>(self, start: u32, end: u32) -> [T; M] {
3-
assert(start + M == end, "slice: invalid slice length");
2+
fn slice<let L: u32>(self, start: u32) -> [T; L] {
3+
let end = start + L;
44
assert(end <= N, "slice: slice end out of bounds");
5-
let mut result = [self[0]; M];
6-
for i in 0..M {
5+
let mut result = [self[0]; L];
6+
for i in 0..L {
77
result[i] = self[start + i];
88
}
99
result
@@ -44,7 +44,7 @@ pub fn pack_bytes<let N: u32>(bytes: [u8; N]) -> [Field; N / 31 + 1] {
4444
let bytes_padded = bytes.pad_end::<(N / 31 + 1) * 31>(0);
4545
let mut res = [0 as Field; N / 31 + 1];
4646
for i in 0..N / 31 + 1 {
47-
let chunk = bytes_padded.slice::<31>(i * 31, i * 31 + 31);
47+
let chunk = bytes_padded.slice::<31>(i * 31);
4848
res[i] = field_from_bytes(chunk);
4949
}
5050
res
@@ -65,7 +65,7 @@ fn field_from_bytes<let N: u32>(bytes: [u8; N]) -> Field {
6565
mod tests {
6666
#[test]
6767
fn test_slice() {
68-
assert([1, 2, 3, 4, 5].slice::<3>(1, 4) == [2, 3, 4]);
68+
assert([1, 2, 3, 4, 5].slice::<3>(1) == [2, 3, 4]);
6969
}
7070

7171
#[test]

src/lib.nr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ mod string;
44
mod tables;
55
mod array;
66

7-
pub use string::{to_hex_string_bytes, str_to_u64};
8-
pub use math::{clamp, div_ceil, sqrt::sqrt};
97
pub use array::pack_bytes;
8+
pub use math::{clamp, div_ceil, sqrt::sqrt};
9+
pub use string::{str_to_u64, to_hex_string_bytes};
1010

1111
trait ArrayExtensions<T, let N: u32> {
12-
fn slice<let M: u32>(self, start: u32, end: u32) -> [T; M];
12+
fn slice<let L: u32>(self, start: u32) -> [T; L];
1313
fn concat<let M: u32>(self, other: [T; M]) -> [T; N + M];
1414
fn pad_start<let M: u32>(self, pad_value: T) -> [T; M];
1515
fn pad_end<let M: u32>(self, pad_value: T) -> [T; M];

src/math.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
pub(crate) mod sqrt;
22
pub(crate) mod numeric;
33

4-
use std::{ops::{Add, Div, Rem}, cmp::Eq};
54
use numeric::Numeric;
5+
use std::{cmp::Eq, ops::{Add, Div, Rem}};
66

77
pub fn clamp<T>(x: T, min: T, max: T) -> T
88
where

src/math/sqrt.nr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use std::{ops::{Mul, Div, Add}, cmp::Ord};
21
use crate::math::numeric::Numeric;
2+
use std::{cmp::Ord, ops::{Add, Div, Mul}};
33

44
// TODO: check if this is correct
55
pub fn sqrt<T>(value: T) -> T

src/tables.nr

Lines changed: 81 additions & 162 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,22 @@
22
pub(crate) global ASCII_TO_NUMBER: [u8; 128] = [
33
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
44
/* */
5-
0,
6-
/*"!"*/
7-
0,
8-
/* " */
9-
0,
10-
/*"#"*/
11-
0,
12-
/*"$"*/
13-
0,
14-
/*"%"*/
15-
0,
16-
/*"&"*/
17-
0,
18-
/*"'"*/
19-
0,
20-
/*"("*/
21-
0,
22-
/*")"*/
23-
0,
24-
/*"*"*/
25-
0,
26-
/*"+"*/
27-
0,
28-
/*","*/
29-
0,
30-
/*"-"*/
31-
0,
32-
/*"."*/
33-
0,
34-
/*"/"*/
35-
0,
36-
/*"0"*/
5+
0, /*"!"*/
6+
0, /* " */
7+
0, /*"#"*/
8+
0, /*"$"*/
9+
0, /*"%"*/
10+
0, /*"&"*/
11+
0, /*"'"*/
12+
0, /*"("*/
13+
0, /*")"*/
14+
0, /*"*"*/
15+
0, /*"+"*/
16+
0, /*","*/
17+
0, /*"-"*/
18+
0, /*"."*/
19+
0, /*"/"*/
20+
0, /*"0"*/
3721
0, // numeric value
3822
/*"1"*/
3923
1, // numeric value
@@ -54,143 +38,78 @@ pub(crate) global ASCII_TO_NUMBER: [u8; 128] = [
5438
/*"9"*/
5539
9, // numeric value
5640
/*":"*/
57-
0,
58-
/*";"*/
59-
0,
60-
/*"<"*/
61-
0,
62-
/*"="*/
63-
0,
64-
/*">"*/
65-
0,
66-
/*"?"*/
67-
0,
68-
/*"@"*/
69-
0,
70-
/*"A"*/
71-
0,
72-
/*"B"*/
73-
0,
74-
/*"C"*/
75-
0,
76-
/*"D"*/
77-
0,
78-
/*"E"*/
79-
0,
80-
/*"F"*/
81-
0,
82-
/*"G"*/
83-
0,
84-
/*"H"*/
85-
0,
86-
/*"I"*/
87-
0,
88-
/*"J"*/
89-
0,
90-
/*"K"*/
91-
0,
92-
/*"L"*/
93-
0,
94-
/*"M"*/
95-
0,
96-
/*"N"*/
97-
0,
98-
/*"O"*/
99-
0,
100-
/*"P"*/
101-
0,
102-
/*"Q"*/
103-
0,
104-
/*"R"*/
105-
0,
106-
/*"S"*/
107-
0,
108-
/*"T"*/
109-
0,
110-
/*"U"*/
111-
0,
112-
/*"V"*/
113-
0,
114-
/*"W"*/
115-
0,
116-
/*"X"*/
117-
0,
118-
/*"Y"*/
119-
0,
120-
/*"Z"*/
121-
0,
122-
/*"["*/
41+
0, /*";"*/
42+
0, /*"<"*/
43+
0, /*"="*/
44+
0, /*">"*/
45+
0, /*"?"*/
46+
0, /*"@"*/
47+
0, /*"A"*/
48+
0, /*"B"*/
49+
0, /*"C"*/
50+
0, /*"D"*/
51+
0, /*"E"*/
52+
0, /*"F"*/
53+
0, /*"G"*/
54+
0, /*"H"*/
55+
0, /*"I"*/
56+
0, /*"J"*/
57+
0, /*"K"*/
58+
0, /*"L"*/
59+
0, /*"M"*/
60+
0, /*"N"*/
61+
0, /*"O"*/
62+
0, /*"P"*/
63+
0, /*"Q"*/
64+
0, /*"R"*/
65+
0, /*"S"*/
66+
0, /*"T"*/
67+
0, /*"U"*/
68+
0, /*"V"*/
69+
0, /*"W"*/
70+
0, /*"X"*/
71+
0, /*"Y"*/
72+
0, /*"Z"*/
73+
0, /*"["*/
12374
0, // an array
12475
/*"\"*/
125-
0,
126-
/*"]"*/
127-
0,
128-
/*"^"*/
129-
0,
130-
/*"_"*/
131-
0,
132-
/*"`"*/
133-
0,
134-
/*"a"*/
135-
0,
136-
/*"b"*/
137-
0,
138-
/*"c"*/
139-
0,
140-
/*"d"*/
141-
0,
142-
/*"e"*/
143-
0,
144-
/*"f"*/
76+
0, /*"]"*/
77+
0, /*"^"*/
78+
0, /*"_"*/
79+
0, /*"`"*/
80+
0, /*"a"*/
81+
0, /*"b"*/
82+
0, /*"c"*/
83+
0, /*"d"*/
84+
0, /*"e"*/
85+
0, /*"f"*/
14586
0, // "0"
14687
/*"g"*/
147-
0,
148-
/*"h"*/
149-
0,
150-
/*"i"*/
151-
0,
152-
/*"j"*/
153-
0,
154-
/*"k"*/
155-
0,
156-
/*"l"*/
157-
0,
158-
/*"m"*/
159-
0,
160-
/*"n"*/
161-
0,
162-
/*"o"*/
163-
0,
164-
/*"p"*/
165-
0,
166-
/*"q"*/
167-
0,
168-
/*"r"*/
169-
0,
170-
/*"s"*/
171-
0,
172-
/*"t"*/
88+
0, /*"h"*/
89+
0, /*"i"*/
90+
0, /*"j"*/
91+
0, /*"k"*/
92+
0, /*"l"*/
93+
0, /*"m"*/
94+
0, /*"n"*/
95+
0, /*"o"*/
96+
0, /*"p"*/
97+
0, /*"q"*/
98+
0, /*"r"*/
99+
0, /*"s"*/
100+
0, /*"t"*/
173101
0, // "0"
174102
/*"u"*/
175-
0,
176-
/*"v"*/
177-
0,
178-
/*"w"*/
179-
0,
180-
/*"x"*/
181-
0,
182-
/*"y"*/
183-
0,
184-
/*"z"*/
185-
0,
186-
/*"{"*/
103+
0, /*"v"*/
104+
0, /*"w"*/
105+
0, /*"x"*/
106+
0, /*"y"*/
107+
0, /*"z"*/
108+
0, /*"{"*/
187109
0, // an object
188110
/*"|"*/
189-
0,
190-
/*"}"*/
191-
0,
192-
/*"~"*/
193-
0,
194-
/*DEL*/
111+
0, /*"}"*/
112+
0, /*"~"*/
113+
0, /*DEL*/
195114
0,
196115
];

0 commit comments

Comments
 (0)