PLATFORM
  • Tails

    Create websites with TailwindCSS

  • Wave

    Start building the next great SAAS

  • Pines

    Alpine & Tailwind UI Library

  • Auth

    Plug'n Play Authentication for Laravel

  • Designer comingsoon

    Create website designs with AI

  • DevBlog comingsoon

    Blog platform for developers

  • Static

    Build a simple static website

  • SaaS Adventure

    21-day program to build a SAAS

Don't panic on Err Result

fn main() {
    let error: Result<(), &str> = Err("error"); // Error

    // Show error instead of panic
    match error {
        Ok(_) => println!("Ok"),
        Err(e) => println!("Error: {}", e),
    }

    println!("Still running ๐Ÿ•");

    // Output:
    // Error: error
    // Still running ๐Ÿ•
}
BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. The function returns a Result<T, E> type. The Ok(T) value holds a T value, and the Err(E) value holds an E value.
2. The match expression is used to decide what to do based on the Result value. In this case,

Snippet By Posandu Mapa

ยท

Created September 12th, 2022

ยท

Report Snippet