Skip to content

Instantly share code, notes, and snippets.

View sangelxyz's full-sized avatar
🎯
Focusing

sAngelxyz sangelxyz

🎯
Focusing
View GitHub Profile
@sangelxyz
sangelxyz / rust-let-else.rs
Created August 29, 2024 12:56 — forked from jeremychone/rust-let-else.rs
Rust 1.65 - let-else statements - new language feature!!! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q)
//! For youtube video: https://www.youtube.com/watch?v=U-5_bumwH9w&list=PL7r-PXl6ZPcCIOFaL7nVHXZvBmHNhrh_Q
/// Guard pattern with let-else
/// e.g., "my_key: 123"
pub fn key_num_guard_1(item: &str) -> Result<(&str, i32), &'static str> {
let Some((key, val)) = item.split_once(':') else {
return Err("Invalid item");
};
let Ok(val) = val.trim().parse::<i32>() else {
return Err("Invalid item");
open Donald
open System.Data.Common
open System.Data.SQLite
open System.Threading.Tasks
open Giraffe
open Giraffe.ViewEngine
open FsToolkit.ErrorHandling
open Microsoft.AspNetCore.Builder
[<RequireQualifiedAccess>]