@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.
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
@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.
@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.
@nen Thanks! I'll give that a go. I appreciate the assist and advice.
@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>
@lil5 It's my crate. What would I have to do to add that functionality?
@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:
͵υ͵μ͵δρμδ'
@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.
@sdk If I do unwrap:
println!("{}", GreekNumeral::new(args.number).unwrap());
Everything works. Why is that?
clap = { version = "4.0", features = ["derive"] }
arithmos = { version = "0.1.1", path = "../arithmos" }
[[bin]]
name = "greek-numerals-rs"
path = "main.rs" (2/2)
@alebaffa The crate is here.
https://codeberg.org/utricularius/arithmos/src/branch/main/src/lib.rs
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)
write!(f, "Number out of range (must be between 1 and 49,999).")
}
} (2/2)
@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)
@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 }
@sdk It might be easier to read here:
https://codeberg.org/utricularius/arithmos/src/branch/main/src/lib.rs
@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).")
}
}
@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).")
}
}
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.
Let’s check in on my happiness level today: :blobfoxgiggle:
@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!
@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.