Skip to content
This repository was archived by the owner on May 23, 2024. It is now read-only.

Commit 29421e3

Browse files
authored
Merge pull request #1263 from matthiaskrgr/may29
Co-authored-by: Yuki Okushi <[email protected]>
2 parents 5998612 + 25d198a commit 29421e3

File tree

6 files changed

+131
-0
lines changed

6 files changed

+131
-0
lines changed

ices/97007.rs

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
#![feature(adt_const_params, generic_const_exprs)]
2+
#![allow(incomplete_features)]
3+
4+
mod lib {
5+
const N_ISLANDS: usize = 4;
6+
const N_BRIDGES: usize = 7;
7+
const BRIDGES: [(usize, usize); 7] = [(0, 1), (0, 1), (0, 2), (0, 3), (0, 3), (1, 2), (2, 3)];
8+
9+
pub type Matrix = [[usize; N_ISLANDS]; N_ISLANDS];
10+
11+
const EMPTY_MATRIX: Matrix = [[0; N_ISLANDS]; N_ISLANDS];
12+
13+
const fn build(mut matrix: Matrix, (to, from): (usize, usize)) -> Matrix {
14+
matrix[to][from] += 1;
15+
matrix[from][to] += 1;
16+
matrix
17+
}
18+
19+
pub const fn walk(mut matrix: Matrix, from: usize, to: usize) -> Matrix {
20+
matrix[from][to] -= 1;
21+
matrix[to][from] -= 1;
22+
matrix
23+
}
24+
25+
const fn to_matrix(bridges: [(usize, usize); N_BRIDGES]) -> Matrix {
26+
let matrix = EMPTY_MATRIX;
27+
28+
let matrix = build(matrix, bridges[0]);
29+
let matrix = build(matrix, bridges[1]);
30+
let matrix = build(matrix, bridges[2]);
31+
let matrix = build(matrix, bridges[3]);
32+
let matrix = build(matrix, bridges[4]);
33+
let matrix = build(matrix, bridges[5]);
34+
let matrix = build(matrix, bridges[6]);
35+
36+
matrix
37+
}
38+
39+
const BRIDGE_MATRIX: [[usize; N_ISLANDS]; N_ISLANDS] = to_matrix(BRIDGES);
40+
41+
pub struct Walk<const CURRENT: usize, const REMAINING: Matrix> {
42+
_p: (),
43+
}
44+
45+
impl Walk<0, BRIDGE_MATRIX> {
46+
pub const fn new() -> Self {
47+
Self { _p: () }
48+
}
49+
}
50+
51+
impl<const CURRENT: usize, const REMAINING: Matrix> Walk<CURRENT, REMAINING> {
52+
pub fn proceed_to<const NEXT: usize>(
53+
self,
54+
) -> Walk<NEXT, { walk(REMAINING, CURRENT, NEXT) }> {
55+
Walk { _p: () }
56+
}
57+
}
58+
59+
pub struct Trophy {
60+
_p: (),
61+
}
62+
63+
impl<const CURRENT: usize> Walk<CURRENT, EMPTY_MATRIX> {
64+
pub fn collect_prize(self) -> Trophy {
65+
Trophy { _p: () }
66+
}
67+
}
68+
}
69+
70+
pub use lib::{Trophy, Walk};
71+
72+
fn main() {
73+
// Example, taking the first step
74+
let _ = Walk::new().proceed_to::<1>();
75+
}

ices/97047-1.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#![feature(adt_const_params, generic_const_exprs)]
2+
3+
pub struct Changes<const CHANGES: &'static [&'static str]>
4+
where
5+
[(); CHANGES.len()]:,
6+
{
7+
changes: [usize; CHANGES.len()],
8+
}
9+
10+
impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
11+
where
12+
[(); CHANGES.len()]:,
13+
{
14+
pub const fn new() -> Self {
15+
Self {
16+
changes: [0; CHANGES.len()],
17+
}
18+
}
19+
}
20+
21+
pub fn main() {}

ices/97047-2.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#![feature(adt_const_params, generic_const_exprs)]
2+
3+
pub struct Changes<const CHANGES: &'static [&'static str]>
4+
where
5+
[(); CHANGES.len()]:,
6+
{
7+
changes: [usize; CHANGES.len()],
8+
}
9+
10+
impl<const CHANGES: &'static [&'static str]> Changes<CHANGES>
11+
where
12+
[(); CHANGES.len()]:,
13+
{
14+
pub fn combine(&mut self, other: &Self) {
15+
for _change in &self.changes {}
16+
}
17+
}
18+
19+
pub fn main() {}

ices/97193.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
extern {
2+
fn a(&mut self) {
3+
fn b(buf: &Self) {
4+
}

ices/97194.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
extern "" {
2+
fn bget(&self, index: [usize; Self::DIM]) -> bool {
3+
type T;
4+
type T<'a> = &'a str;
5+
}
6+
7+
fn main() {}

ices/97197.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
fn f() {
2+
g((), ());
3+
}
4+
5+
pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) {}

0 commit comments

Comments
 (0)