{"id":20910122,"url":"https://github.com/viperproject/rust-contracts","last_synced_at":"2025-05-13T07:31:35.129Z","repository":{"id":45007757,"uuid":"199682272","full_name":"viperproject/rust-contracts","owner":"viperproject","description":null,"archived":false,"fork":false,"pushed_at":"2022-01-14T08:15:26.000Z","size":30,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2023-03-23T02:05:45.281Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/viperproject.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-30T15:47:25.000Z","updated_at":"2023-01-15T06:32:56.000Z","dependencies_parsed_at":"2022-09-24T21:40:45.249Z","dependency_job_id":null,"html_url":"https://github.com/viperproject/rust-contracts","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viperproject%2Frust-contracts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viperproject%2Frust-contracts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viperproject%2Frust-contracts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/viperproject%2Frust-contracts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/viperproject","download_url":"https://codeload.github.com/viperproject/rust-contracts/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225188064,"owners_count":17434993,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-18T14:13:58.950Z","updated_at":"2024-11-18T14:13:59.638Z","avatar_url":"https://github.com/viperproject.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Rust Contracts (Deprecated)\n===========================\n\n**This project is not actively maintained. If you want something that is maintained, please see Prusti and its contracts library: https://github.com/viperproject/prusti-dev**\n\n\n[![Build Status](https://travis-ci.org/viperproject/rust-contracts.svg?branch=master)](https://travis-ci.org/viperproject/rust-contracts)\n\nThis crate offers the syntax to specify the *contract* of Rust functions (e.g. functional specification).\n\nBy default all contracts are ignored.\n\nVerification tools can plug-in their implementation of contracts, in order to check the contracts statically or at runtime, using the technique of their choice.\n\n\nExample of contract\n-------------------\n\nContracts can be used to specify the requirements and the guarantees of a function:\n\n```rust\n#[requires(x \u003e 5)]\n#[ensures(result \u003e= 0)]\nfn foo(x: i32) -\u003e i32 {\n    if x \u003c= 5 {\n        panic!();\n    }\n    (x - 1) / 2\n}\n```\n\n\nCompile ignoring contracts\n--------------------------\n\nBe default, contracts are ignored.\n\n```bash\ncargo run --example true\n```\n\nNote that the example does not print messages to standard output.\n\n\nCustom implementation of contracts\n----------------------------------\n\nThe behaviour of contracts can be configured.\nAs an example, we provide in the `example_verification_tool` and `example_contracts_impl` folders an implementation that prints the contracts at runtime.\n\n```bash\n# Build the implementation of contracts and the compilation tool\ncargo build --manifest-path example_contracts_impl/Cargo.toml\ncargo build --manifest-path example_verification_tool/Cargo.toml\n\n# Compile and run an example with the modified contracts behaviour\nexport RUST_CONTRACTS_LIB=example_contracts_impl/target/debug/libexample_contracts_impl.so\ncargo clean\nexample_verification_tool/target/debug/cargo-tool run --example true\n```\n\nYou can see from the output that the contract is printed while running the example.\n\n\nLicense\n-------\n\nLicensed under either of\n\n- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)\n- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT) at your option.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviperproject%2Frust-contracts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviperproject%2Frust-contracts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviperproject%2Frust-contracts/lists"}