oli-obk
a maintainer of the Rust compiler
Rust evangelism
#[no_mangle]
extern "C" fn malloc(_n: usize) -> *const u8 {
std::ptr::dangling()
}
error: expected one of `;` or `{`, found `<`
--> src/lib.rs:1:8
|
1 | mod foo<T> {}
| ^ expected one of `;` or `{`
Ferrocene (https://ferrocene.dev)
It’s official: Ferrocene is ISO 26262 and IEC 61508 qualified!
use core::contracts::*;
#[requires(x.bar > 50)]
#[ensures(|ret| *ret > 100)]
fn foo(x: Bar) -> i32 {
x.bar + 50
}
subtype Non_Zero is Integer range 1..Integer'Last;
subtype Non_Null_Foo is not null Foo;
use std::num::NonZeroU32;
type NonNullFoo = std::ptr::NonNull<Foo>;
type Foo = u32; |
type Bar = u32; |
---|---|
let x: Foo = 1; |
let x: Bar = 1; |
match foo {
1..100 => {}
_ => {}
}
case Foo is
when 1 .. 100 => null;
when others => null;
end case;
match bar {
Dog | Cat | Bat => {}
_ => {}
}
case Bar is
when Dog | Cat | Bat => null;
when others => null;
end case;
match (foo, bar) {
(1..10, Dog | Cat) => {}
(10..20, Dog | Cat | Bat) => {}
(_, Bat) => {}
_ => {}
}
subtype Non_Zero is Integer range 1..Integer'Last;
subtype Non_Null is not null SomePointer;
type NonZeroU32 = u32 is 1..;
// non-null is WIP
type NonNull = *const Thing is !null;
u32 is 1..
is always the same as any other u32 is 1..
let x: u32 is 1.. = 42;
subtype Non_Zero is Integer range 1..Integer'Last;
X: Non_Zero := 42;
let a: u32 = 42;
let x: u32 is 1.. = transmute(a);
subtype Non_Zero is Integer range 1..Integer'Last;
A: Integer := 42;
X: Non_Zero := A;
Without specifying the pattern again:
type Grade = u32 is 1..=6;
type Passing = u32 is 1..=5;
let grade: Grade = read_from_somewhere();
if let Some(passing) = Passing::try_from(grade) {
// yay
}
type SomePercent = Option<u32> is Some(0..=100);
type Disjunctive = u32 is 0..=100 | 500..=1000;
type Tuple = (u32, &str) is (0..=100, "cake" | "fruit");
unsafe
opt-out