“UnlemAr_OR_ELSE à Rust” Réponses codées

UnlemAr_OR_ELSE à Rust

// You can use .unwrap_or_else method instead of Result enum

use std::path::Path;
use std::fs;

fn main() {
  let path = Path::new("hello.txt");
  let content = String::from("hello world");

  fs::write(path, content).unwrap_or_else(|error| {
      panic!("an error occurred while writing the file: {}", error)
  })
}
Ahmad Khaefi

UnlemAr_OR_ELSE à Rust

// You can use .unwrap_or_else method instead of Result enum

use std::path::Path;
use std::fs;

fn main() {
  let path = Path::new("hello.txt");
  let content = String::from("hello world");

  fs::write(path, content).unwrap_or_else(|error| {
      panic!("an error occurred while writing the file: {}", error)
  })
}
Ahmad Khaefi

UnlemAr_OR_ELSE à Rust

// You can use .unwrap_or_else method instead of Result enum

use std::path::Path;
use std::fs;

fn main() {
  let path = Path::new("hello.txt");
  let content = String::from("hello world");

  fs::write(path, content).unwrap_or_else(|error| {
      panic!("an error occurred while writing the file: {}", error)
  })
}
Ahmad Khaefi

Réponses similaires à “UnlemAr_OR_ELSE à Rust”

Questions similaires à “UnlemAr_OR_ELSE à Rust”

Plus de réponses similaires à “UnlemAr_OR_ELSE à Rust” dans Rust

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code