Vincent :coffeecup:

Trans rights are human rights | 🏳️‍⚧️🏳️‍🌈 ally | #coffee | #SiliconValley | #atheism | #bagpipes | #AmWriting | #Latin | #Caturday | #Newts

Profile photo: a cute newt! Drawn by
@heyheymomo

Banner: nickel ferrules of my bagpipes' drones, pattern of a Celtic knot, made by Colin Kyo Pipes

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@skinnylatte Excellent words for the heretofore indescribable feeling in my gut when I see tech press releases and get a sinking feeling instead of a sense of wonder.

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@wall_e @GossiTheDog My BIL had me watch that ep of Black Mirror. Still gives me nightmares years later. Well acted, but disturbing as fuck. Also, misogynistic, which years later I see less as the writers’ sexism but more as commentary on how the patriarchy would use the technology as a sex police.

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@nen Thanks! I'll give that a go. I appreciate the assist and advice.

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@nen thanks! When I try:

let num: GreekNumeral = GreekNumeral::new(args.number)?;

the `?` operator can only be used in a function that returns `Result` or `Option`

But that's weird to me, as the contructor for GreekNumeral returns

Result<Self, OutOfRangeError>

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@lil5 It's my crate. What would I have to do to add that functionality?

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@nen You're right, it compiles, but I don't completely understand the syntax yet. If I do:

println!("{:?}", GreekNumeral::new(args.number));

the output isn't what I want:
Ok(GreekNumeral(444444))

should be:
͵υ͵μ͵δρμδ'

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@nen No particular reason. I'm learning by example, and the crate I'm using as exemplar does it the way I posted.

I get that error. I just didn't post it. Only so many characters in a post.

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@sdk If I do unwrap:

println!("{}", GreekNumeral::new(args.number).unwrap());

Everything works. Why is that?

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

clap = { version = "4.0", features = ["derive"] }
arithmos = { version = "0.1.1", path = "../arithmos" }

[[bin]]
name = "greek-numerals-rs"
path = "main.rs" (2/2)

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@alebaffa The crate is here.
codeberg.org/utricularius/arit

Test program:

1 use arithmos::GreekNumeral;
2 use clap::Parser;
3
4 #[derive(Parser)]
5 struct Cli {
6 number: u32,
7 }
8
9 fn main() -> fmt::Result {
10 let args = Cli::parse();
11
12 println!("{}", GreekNumeral::new(args.number));
13 }

Test program's Cargo.toml

[package]
name = "greek-numerals-rs"
version = "0.0.1"
edition = "2021"
rust-version = "1.87.0"

[dependencies] (1/2)

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

write!(f, "Number out of range (must be between 1 and 49,999).")
}
} (2/2)

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@sdk I am trying that rn. It doesn't like it if I put it in the crate. So I tried the testing program, and it doesn't like it there either. Both places throw this error:

only traits defined in the current crate can be implemented for types defined outside of the crate for this snippet:

impl fmt::Display for Result<GreekNumeral, OutOfRangeError> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { (1/2)

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@liujiacai The testing function looks like this. Error is on line 12

1 use arithmos::GreekNumeral;
2 use clap::Parser;
3
4 #[derive(Parser)]
5 struct Cli {
6 number: u32,
7 }
8
9 fn main() {
10 let args = Cli::parse();
11
12 println!("{}", GreekNumeral::new(args.number));
13 }

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@sdk It looks like this:

pub struct OutOfRangeError;

impl fmt::Display for OutOfRangeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Number out of range (must be between 1 and 49,999).")
}
}

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

@liujiacai pub struct OutOfRangeError;

impl fmt::Display for OutOfRangeError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Number out of range (must be between 1 and 49,999).")
}
}

Vincent :coffeecup:vincent@mastodon.coffee
2025-05-22

Are #rust developers active on Mastodon? If so, and someone has a moment, I'd like to know why my rust program is throwing a particular error.

`Result<GreekNumeral, OutOfRangeError>` doesn't implement `std::fmt::Display`

But the thing is... it does impl Display.

So I'm wondering what I'm doing wrong.

Vincent :coffeecup:vincent@mastodon.coffee
2025-04-21

Let’s check in on my happiness level today: :blobfoxgiggle:

TSLA stock ticker for April 21st at 10:21 AM. 226.09 -15.27 6.33%
Vincent :coffeecup:vincent@mastodon.coffee
2025-04-18

@pojntfx I haven't been to Vancouver in ages. It is quite lovely, even in the winter (which was when I visited). I'm so glad you're enjoying your home!

Vincent :coffeecup:vincent@mastodon.coffee
2025-04-16

@fuzzykb I ripped my thumbnail today on a refrigerator shelf. Half the nail is torn off. It hurt! I’m scared to look at it, but at some point I’m going to have to shower and redress the wound.

Client Info

Server: https://mastodon.social
Version: 2025.04
Repository: https://github.com/cyevgeniy/lmst