safe-rust 0.1.0

A safety-oriented Rust crate that ensures your code is safe.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented2 out of 2 items with examples
  • Size
  • Source code size: 7.47 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.03 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 11s Average build duration of successful builds.
  • all releases: 11s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • guhhammer/safe-rust
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • guhhammer

safe-rust

safe-rust is a lightweight Rust crate designed to make your code safe.

Rust is already safe, but sometimes that’s not enough.

In situations where safety is critical, explicit, and non-negotiable, safe-rust allows you to clearly communicate that intent.

Features

  • Ensures expressions are safe
  • Zero-cost abstraction
  • No unsafe code
  • Minimal API surface
  • Explicit safety semantics

Installation

[dependencies]
safe-rust = "0.1"

Usage

use safe_rust::safe;

fn main() {
    // Guarantees that 2 + 2 is performed within safe boundaries
    let result = safe!(2 + 2);
    println!("{result}");
}

Recommendations

Safety

This crate contains no unsafe code.

All expressions passed to safe! are evaluated safely, as intended by the Rust language and its guarantees.

  • If an expression is unsafe, it should not compile.

  • If it compiles, it is safe.

Performance

There is no measurable performance impact. The macro expands directly to the enclosed expression, introducing no additional:

  • Instructions

  • Allocations

  • Runtime checks

Decision Matrix

When should I use this?

  • When you want to explicitly mark code as safe.

  • When safety is a concern.

  • When clarity matters.

  • When reviewing critical code paths.

  • When you want to be absolutely sure.

When should I not use this?

  • When safety is implied.

  • When ambiguity is acceptable.

  • When you are comfortable assuming safety.