Skip to content

Commit

Permalink
.expect("msg") is formatted internally
Browse files Browse the repository at this point in the history
  • Loading branch information
correabuscar committed Mar 25, 2024
1 parent 26b4f4a commit 7fa3764
Show file tree
Hide file tree
Showing 13 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/expect_msg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
7 changes: 7 additions & 0 deletions rust/05_sandbox/panics/expect_msg/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions rust/05_sandbox/panics/expect_msg/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "expect_msg"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/expect_msg/e
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vim src/main.rs
4 changes: 4 additions & 0 deletions rust/05_sandbox/panics/expect_msg/g
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

export RUST_BACKTRACE=1
cargo clean; cargo run
6 changes: 6 additions & 0 deletions rust/05_sandbox/panics/expect_msg/gmy
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
cargo clean
export RUSTC="$(realpath ./myrust)"
#export RUST_BACKTRACE=1
cargo run ; ec="$?"
echo "exit code: $ec"
6 changes: 6 additions & 0 deletions rust/05_sandbox/panics/expect_msg/myrust
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

export LD_LIBRARY_PATH="/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/lib:/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/lib/rustlib/x86_64-unknown-linux-gnu/lib"
export RUSTC="/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/bin/rustc"

/var/tmp/portage/dev-lang/rust-1.75.0-r1/work/rustc-1.75.0-src/build/x86_64-unknown-linux-gnu/stage1/bin/rustc "$@"
16 changes: 16 additions & 0 deletions rust/05_sandbox/panics/expect_msg/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use std::fmt::{Display, self};

struct MyStruct;

impl Display for MyStruct {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
None::<i32>.expect("oh snap");//FIXME: no message
todo!();//ignore this, it's for return
}
}

fn main() {
//None::<u32>.expect("unexpected None");// correctly shows
let instance = MyStruct;
assert!(false, "oh no, '{}' was unexpected", instance);
}
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/forking_does_what
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/global_count_after_fork_isnt_one
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/overriden_global_allocator
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/sigabrt_catch_attempt
1 change: 1 addition & 0 deletions rust/05_sandbox/panics/tests

0 comments on commit 7fa3764

Please sign in to comment.