Skip to content

Commit

Permalink
Add 82956
Browse files Browse the repository at this point in the history
  • Loading branch information
fanninpm committed Mar 12, 2021
1 parent 276d644 commit 98afd10
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions ices/82956.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/bin/bash

rustc --crate-type=lib --crate-name=ordes - <<'EOF'
#![feature(const_generics, const_evaluatable_checked, array_map)]
use std::array::IntoIter;
pub struct ConstCheck<const CHECK: bool>;
pub trait True {}
impl True for ConstCheck<true> {}
pub trait OrdesDec {
type Newlen;
type Output;
fn pop(self) -> (Self::Newlen, Self::Output);
}
impl<T, const N: usize> OrdesDec for [T; N]
where
ConstCheck<{N > 1}>: True,
[T; N - 1]: Sized,
{
type Newlen = [T; N - 1];
type Output = T;
fn pop(self) -> (Self::Newlen, Self::Output) {
let mut iter = IntoIter::new(self);
let end = iter.next_back().unwrap();
let new = [(); N - 1].map(move |()| iter.next().unwrap());
(new, end)
}
}
EOF

rustc -L. - <<'EOF'
extern crate ordes;
use ordes::OrdesDec;
fn main() {
let foo = [0u8, 1, 2, 3, 4];
let (foo, pop) = foo.pop();
}
EOF

0 comments on commit 98afd10

Please sign in to comment.