Skip to content

Commit f2bd474

Browse files
committed
fix test
1 parent 4470c1c commit f2bd474

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/chunk.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! let chunk2 = Chunk::new().prepend(3).prepend(4);
1818
//! let combined = chunk1.concat(chunk2);
1919
//!
20-
//! assert_eq!(combined.as_vec(), vec![&1, &2, &3, &4]);
20+
//! assert_eq!(combined.as_vec(), vec![2, 1, 4, 3]);
2121
//! ```
2222
2323
use std::rc::Rc;
@@ -51,7 +51,7 @@ use std::rc::Rc;
5151
/// let other_chunk = Chunk::new().prepend(3).prepend(4);
5252
/// let combined = chunk.concat(other_chunk);
5353
///
54-
/// assert_eq!(combined.as_vec(), vec![&1, &2, &3, &4]);
54+
/// assert_eq!(combined.as_vec(), vec![2,1, 4, 3]);
5555
/// ```
5656
///
5757
/// # References
@@ -118,7 +118,7 @@ impl<A> Chunk<A> {
118118
/// use tailcall_chunk::Chunk;
119119
///
120120
/// let chunk = Chunk::new().prepend(1).prepend(2);
121-
/// assert_eq!(chunk.as_vec(), vec![&1, &2]);
121+
/// assert_eq!(chunk.as_vec(), vec![2, 1]);
122122
/// ```
123123
pub fn prepend(self, a: A) -> Self {
124124
Chunk::Prepend(a, Rc::new(self))
@@ -140,7 +140,7 @@ impl<A> Chunk<A> {
140140
/// let chunk1 = Chunk::new().prepend(1).prepend(2);
141141
/// let chunk2 = Chunk::new().prepend(3).prepend(4);
142142
/// let combined = chunk1.concat(chunk2);
143-
/// assert_eq!(combined.as_vec(), vec![&1, &2, &3, &4]);
143+
/// assert_eq!(combined.as_vec(), vec![2,1, 4,3]);
144144
/// ```
145145
pub fn concat(self, other: Chunk<A>) -> Self {
146146
if self.is_null() {
@@ -174,7 +174,7 @@ impl<A> Chunk<A> {
174174
/// // This operation is O(1) and doesn't actually transform the elements
175175
/// let doubled = chunk.transform(|x| x * 2);
176176
/// // The transformation happens here, when we call as_vec()
177-
/// assert_eq!(doubled.as_vec(), vec![&6, &4, &2]);
177+
/// assert_eq!(doubled.as_vec(), vec![6, 4, 2]);
178178
/// ```
179179
pub fn transform(self, f: impl Fn(A) -> A + 'static) -> Self {
180180
self.transform_flatten(move |a| Chunk::new().prepend(f(a)))
@@ -203,7 +203,7 @@ impl<A> Chunk<A> {
203203
/// // This operation is O(1) and doesn't actually transform the elements
204204
/// let duplicated = chunk.transform_flatten(|x| Chunk::new().prepend(x).prepend(x));
205205
/// // The transformation happens here, when we call as_vec()
206-
/// assert_eq!(duplicated.as_vec(), vec![&2, &2, &1, &1]);
206+
/// assert_eq!(duplicated.as_vec(), vec![2, 2, 1, 1]);
207207
/// ```
208208
pub fn transform_flatten(self, f: impl Fn(A) -> Chunk<A> + 'static) -> Chunk<A> {
209209
Chunk::FlatMap(Rc::new(self), Rc::new(f))
@@ -219,7 +219,7 @@ impl<A> Chunk<A> {
219219
/// use tailcall_chunk::Chunk;
220220
///
221221
/// let chunk = Chunk::new().prepend(1).prepend(2).prepend(3);
222-
/// assert_eq!(chunk.as_vec(), vec![&1, &2, &3]);
222+
/// assert_eq!(chunk.as_vec(), vec![3, 2, 1]);
223223
/// ```
224224
pub fn as_vec(&self) -> Vec<A>
225225
where
@@ -350,9 +350,9 @@ mod tests {
350350
let chunk3 = chunk1.clone().prepend(4);
351351

352352
// Verify that modifications create new structures while preserving the original
353-
assert_eq!(chunk1.as_vec(), vec![1, 2]);
354-
assert_eq!(chunk2.as_vec(), vec![1, 2, 3]);
355-
assert_eq!(chunk3.as_vec(), vec![1, 2, 4]);
353+
assert_eq!(chunk1.as_vec(), vec![2, 1]);
354+
assert_eq!(chunk2.as_vec(), vec![3, 2, 1]);
355+
assert_eq!(chunk3.as_vec(), vec![4, 2, 1]);
356356
}
357357

358358
#[test]
@@ -365,7 +365,7 @@ mod tests {
365365

366366
// Test with floating point numbers
367367
let float_chunk = Chunk::new().prepend(3.14).prepend(2.718);
368-
assert_eq!(float_chunk.as_vec(), vec![3.14, 2.718]);
368+
assert_eq!(float_chunk.as_vec(), vec![2.718, 3.14]);
369369

370370
// Test with boolean values
371371
let bool_chunk = Chunk::new().prepend(true).prepend(false).prepend(true);
@@ -380,7 +380,7 @@ mod tests {
380380
Rc::new(chunk),
381381
Rc::new(|x| Chunk::new().prepend(x * 2).prepend(x)),
382382
);
383-
assert_eq!(mapped.as_vec(), vec![2, 1, 4, 2]);
383+
assert_eq!(mapped.as_vec(), vec![2, 4, 1, 2]);
384384

385385
// Test flat_map with empty chunk
386386
let empty: Chunk<i32> = Chunk::new();
@@ -390,10 +390,8 @@ mod tests {
390390
// Test nested flat_map
391391
let chunk = Chunk::new().prepend(1).prepend(2);
392392
let first_map = Chunk::FlatMap(Rc::new(chunk), Rc::new(|x| Chunk::new().prepend(x * 2)));
393-
let nested_map = Chunk::FlatMap(
394-
Rc::new(first_map),
395-
Rc::new(|x| Chunk::new().prepend(x + 1)),
396-
);
397-
assert_eq!(nested_map.as_vec(), vec![3, 5]);
393+
let nested_map =
394+
Chunk::FlatMap(Rc::new(first_map), Rc::new(|x| Chunk::new().prepend(x + 1)));
395+
assert_eq!(nested_map.as_vec(), vec![5, 3]);
398396
}
399397
}

0 commit comments

Comments
 (0)