Skip to content

Instantly share code, notes, and snippets.

@vakaras
vakaras / playground.rs
Created October 7, 2019 15:23
Code shared from the Rust Playground
#![feature(proc_macro_hygiene)]
use rust_contracts::{requires, ensures, invariant};
#[requires(*m >= 2)]
#[ensures(old(*m) == result.len())]
fn create_fib_array(m: &mut usize) -> Vec<usize> {
let mut fib_array = Vec::new();
fib_array.push(0);
fib_array.push(1);
let mut i = 2;
while i != *m {
@vakaras
vakaras / playground.rs
Created October 7, 2019 15:22
Code shared from the Rust Playground
// Imports macros for specifying postconditions.
use rust_contracts::ensures;
#[ensures(result >= a && result >= b)]
fn max(a: i32, b: i32) -> i32 {
if a < b { b } else { a }
}
fn main() {
let _ = max(1, 2);
@vakaras
vakaras / playground.rs
Created May 16, 2019 14:14
Code shared from the Rust Playground
extern crate prusti_contracts;
pub struct VecWrapperUSize{
v: Vec<usize>
}
impl VecWrapperUSize {
#[trusted]
#[ensures="result.len() == 0"]
pub fn new() -> Self {
@vakaras
vakaras / playground.rs
Created May 16, 2019 14:06
Code shared from the Rust Playground
extern crate prusti_contracts;
pub struct VecWrapperUSize{
v: Vec<usize>
}
impl VecWrapperUSize {
#[trusted]
#[ensures="result.len() == 0"]
pub fn new() -> Self {
@vakaras
vakaras / Dockerfile
Created August 6, 2018 20:18
Marktoberdorf Summer School, Programming by Examples
FROM ubuntu:18.04
MAINTAINER Vytautas Astrauskas "vastrauskas@gmail.com"
ENV DEBIAN_FRONTEND noninteractive
# Install prerequisites.
RUN apt-get update && \
apt-get install -y \
build-essential \
locales \
@vakaras
vakaras / output.txt
Created June 4, 2018 12:05
Compile test output when it has panicking code
$ "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/home/vakaras/tmp/add-polonius-compare-mode/src/test/ui" "--build-base" "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/home/vakaras/tmp/add-polonius-compare-mode/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--nodejs" "/usr/local/bin/node" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstabl