@@ -19,7 +19,7 @@ enum ObjectType {
19
19
20
20
// The top 6 bits of the NodePtr indicate what type of object it is
21
21
impl NodePtr {
22
- pub fn null ( ) -> Self {
22
+ pub fn nil ( ) -> Self {
23
23
Self :: new ( ObjectType :: Bytes , 0 )
24
24
}
25
25
@@ -56,7 +56,7 @@ impl NodePtr {
56
56
57
57
impl Default for NodePtr {
58
58
fn default ( ) -> Self {
59
- Self :: null ( )
59
+ Self :: nil ( )
60
60
}
61
61
}
62
62
@@ -170,11 +170,11 @@ impl Allocator {
170
170
pub fn new_atom ( & mut self , v : & [ u8 ] ) -> Result < NodePtr , EvalErr > {
171
171
let start = self . u8_vec . len ( ) as u32 ;
172
172
if ( self . heap_limit - start as usize ) < v. len ( ) {
173
- return err ( self . null ( ) , "out of memory" ) ;
173
+ return err ( self . nil ( ) , "out of memory" ) ;
174
174
}
175
175
let idx = self . atom_vec . len ( ) ;
176
176
if idx == MAX_NUM_ATOMS {
177
- return err ( self . null ( ) , "too many atoms" ) ;
177
+ return err ( self . nil ( ) , "too many atoms" ) ;
178
178
}
179
179
self . u8_vec . extend_from_slice ( v) ;
180
180
let end = self . u8_vec . len ( ) as u32 ;
@@ -197,15 +197,15 @@ impl Allocator {
197
197
pub fn new_pair ( & mut self , first : NodePtr , rest : NodePtr ) -> Result < NodePtr , EvalErr > {
198
198
let idx = self . pair_vec . len ( ) ;
199
199
if idx == MAX_NUM_PAIRS {
200
- return err ( self . null ( ) , "too many pairs" ) ;
200
+ return err ( self . nil ( ) , "too many pairs" ) ;
201
201
}
202
202
self . pair_vec . push ( IntPair { first, rest } ) ;
203
203
Ok ( NodePtr :: new ( ObjectType :: Pair , idx) )
204
204
}
205
205
206
206
pub fn new_substr ( & mut self , node : NodePtr , start : u32 , end : u32 ) -> Result < NodePtr , EvalErr > {
207
207
if self . atom_vec . len ( ) == MAX_NUM_ATOMS {
208
- return err ( self . null ( ) , "too many atoms" ) ;
208
+ return err ( self . nil ( ) , "too many atoms" ) ;
209
209
}
210
210
let ( ObjectType :: Bytes , idx) = node. node_type ( ) else {
211
211
return err ( node, "(internal error) substr expected atom, got pair" ) ;
@@ -231,11 +231,11 @@ impl Allocator {
231
231
232
232
pub fn new_concat ( & mut self , new_size : usize , nodes : & [ NodePtr ] ) -> Result < NodePtr , EvalErr > {
233
233
if self . atom_vec . len ( ) == MAX_NUM_ATOMS {
234
- return err ( self . null ( ) , "too many atoms" ) ;
234
+ return err ( self . nil ( ) , "too many atoms" ) ;
235
235
}
236
236
let start = self . u8_vec . len ( ) ;
237
237
if self . heap_limit - start < new_size {
238
- return err ( self . null ( ) , "out of memory" ) ;
238
+ return err ( self . nil ( ) , "out of memory" ) ;
239
239
}
240
240
self . u8_vec . reserve ( new_size) ;
241
241
@@ -258,7 +258,7 @@ impl Allocator {
258
258
if counter != new_size {
259
259
self . u8_vec . truncate ( start) ;
260
260
return err (
261
- self . null ( ) ,
261
+ self . nil ( ) ,
262
262
"(internal error) concat passed invalid new_size" ,
263
263
) ;
264
264
}
@@ -353,7 +353,7 @@ impl Allocator {
353
353
}
354
354
}
355
355
356
- pub fn null ( & self ) -> NodePtr {
356
+ pub fn nil ( & self ) -> NodePtr {
357
357
NodePtr :: new ( ObjectType :: Bytes , 0 )
358
358
}
359
359
@@ -429,7 +429,7 @@ fn test_node_as_index() {
429
429
#[ test]
430
430
fn test_atom_eq ( ) {
431
431
let mut a = Allocator :: new ( ) ;
432
- let a0 = a. null ( ) ;
432
+ let a0 = a. nil ( ) ;
433
433
let a1 = a. one ( ) ;
434
434
let a2 = a. new_atom ( & [ 1 ] ) . unwrap ( ) ;
435
435
let a3 = a. new_atom ( & [ 0x5 , 0x39 ] ) . unwrap ( ) ;
@@ -473,12 +473,12 @@ fn test_atom_eq() {
473
473
}
474
474
475
475
#[ test]
476
- fn test_null ( ) {
476
+ fn test_nil ( ) {
477
477
let a = Allocator :: new ( ) ;
478
- assert_eq ! ( a. atom( a. null ( ) ) , b"" ) ;
478
+ assert_eq ! ( a. atom( a. nil ( ) ) , b"" ) ;
479
479
480
- let buf = match a. sexp ( a. null ( ) ) {
481
- SExp :: Atom => a. atom ( a. null ( ) ) ,
480
+ let buf = match a. sexp ( a. nil ( ) ) {
481
+ SExp :: Atom => a. atom ( a. nil ( ) ) ,
482
482
SExp :: Pair ( _, _) => panic ! ( "unexpected" ) ,
483
483
} ;
484
484
assert_eq ! ( buf, b"" ) ;
@@ -549,7 +549,7 @@ fn test_allocate_heap_limit() {
549
549
fn test_allocate_atom_limit ( ) {
550
550
let mut a = Allocator :: new ( ) ;
551
551
// we can allocate 5 atoms total
552
- // keep in mind that we always have 2 pre-allocated atoms for null and one,
552
+ // keep in mind that we always have 2 pre-allocated atoms for nil and one,
553
553
// so with a limit of 5, we only have 3 slots left at this point.
554
554
let _atom = a. new_atom ( b"foo" ) . unwrap ( ) ;
555
555
let _atom = a. new_atom ( b"bar" ) . unwrap ( ) ;
@@ -563,7 +563,7 @@ fn test_allocate_atom_limit() {
563
563
}
564
564
assert_eq ! ( a. new_atom( b"foobar" ) . unwrap_err( ) . 1 , "too many atoms" ) ;
565
565
566
- // the pre-allocated null () and one() also count against the limit, and they
566
+ // the pre-allocated nil () and one() also count against the limit, and they
567
567
// use 0 and 1 bytes respectively
568
568
assert_eq ! ( a. u8_vec. len( ) , MAX_NUM_ATOMS * 3 - 3 - 2 ) ;
569
569
}
@@ -798,7 +798,7 @@ fn test_point_size_error(#[case] fun: TestFun, #[case] size: usize, #[case] expe
798
798
#[ case( test_g2, "pair found, expected G2 point" ) ]
799
799
fn test_point_atom_pair ( #[ case] fun : TestFun , #[ case] expected : & str ) {
800
800
let mut a = Allocator :: new ( ) ;
801
- let n = a. new_pair ( a. null ( ) , a. one ( ) ) . unwrap ( ) ;
801
+ let n = a. new_pair ( a. nil ( ) , a. one ( ) ) . unwrap ( ) ;
802
802
let r = fun ( & a, n) ;
803
803
assert_eq ! ( r. 0 , n) ;
804
804
assert_eq ! ( r. 1 , expected. to_string( ) ) ;
0 commit comments