We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9f64276 commit 5b15751Copy full SHA for 5b15751
core/tests/array.rs
@@ -330,3 +330,32 @@ fn array_map_drop_safety() {
330
assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create);
331
panic!("test succeeded")
332
}
333
+
334
+#[test]
335
+fn cell_allows_array_cycle() {
336
+ use core::cell::Cell;
337
338
+ #[derive(Debug)]
339
+ struct B<'a> {
340
+ a: [Cell<Option<&'a B<'a>>>; 2],
341
+ }
342
343
+ impl<'a> B<'a> {
344
+ fn new() -> B<'a> {
345
+ B { a: [Cell::new(None), Cell::new(None)] }
346
347
348
349
+ let b1 = B::new();
350
+ let b2 = B::new();
351
+ let b3 = B::new();
352
353
+ b1.a[0].set(Some(&b2));
354
+ b1.a[1].set(Some(&b3));
355
356
+ b2.a[0].set(Some(&b2));
357
+ b2.a[1].set(Some(&b3));
358
359
+ b3.a[0].set(Some(&b1));
360
+ b3.a[1].set(Some(&b2));
361
+}
0 commit comments