From 2d0fe4e0cfe86b31a2716eaabbfa6f897e05e589 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Mon, 19 Sep 2022 14:56:32 -0400 Subject: [PATCH 1/6] added linkedin icon --- static/img/linkedin-icon.png | Bin 0 -> 936 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 static/img/linkedin-icon.png diff --git a/static/img/linkedin-icon.png b/static/img/linkedin-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..672f81e20d90ba9dec8094b5bbd11c0c5cb74675 GIT binary patch literal 936 zcmV;Z16TZsP)l=Wv5r3}I-N6UnypjJZqoDdNdN`!0=QAtk`E(#)_j1;OD3!{fcMI;3g zLA~^1l4W}c1hd6fC_*OIRMt|Kc8_vnyLY?4-|nx6-@QBcWe@)D^`6f;=X>t&&v7g& z7ZmX2AOI8rlma>pi2q8#`Q8}xMdC0zHD_ss*i>Eu4c=0?+EfLltBQ2C=rjP0uemq~ z)5$-UHeCDiZs$rE?(pd#=m4AyMc~1}gsqHMjX7Rd0k;F*4BK=7wkzJZdf4ak9;U-b zB?{6n9e~xRUfa_9s!@radICTZkVe2%3RISrKxdN&d{t|g9yJ)7g!V5;4CN?;0i_H+ zwsRR&^BN*cN&W6=Ke zt6|Vc4FI?0I-ZY0_p9*?BVL}Xg?g`>nGMnJNvORPwk819%inDAf}c?-5a7nM1J(n8 zA@6SOXL@-2dR^8XUiC)QfiEGnVXwDpW^9bqy)h7nvnqnKtq59lOjNLJ>Y*&htYv7uTcu55isKb5DuYx81&_&@5i~RRkO<}=APSQ-fHXi*1DLB8k`EA00m zA&6~r%IOW6Pk!^HA%=a!wo;|PfwOIn=b?5QL%qY)JYC?;(|-Z7(phdZt`^Gx0000< KMNUMnLSTXoWu|2S literal 0 HcmV?d00001 From 4b6edd0347e1bb84e0bd060f91a354d3239223b3 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Mon, 19 Sep 2022 15:29:00 -0400 Subject: [PATCH 2/6] added a page with links to stuff --- config.toml | 10 ++++++++++ content/links/index.html | 10 ++++++++++ layouts/partials/author.html | 1 + 3 files changed, 21 insertions(+) create mode 100644 content/links/index.html diff --git a/config.toml b/config.toml index 71360b9..8f367e6 100644 --- a/config.toml +++ b/config.toml @@ -12,9 +12,19 @@ theme = "liquorice" name = "blog" url = "/blog/" [[menu.main]] + identifier = "links" + name = "links" + url = "/links/" + [[menu.main]] + parent = "links" identifier = "github" name = "github" url = "https://github.com/Pagwin-Fedora" + [[menu.main]] + parent = "links" + identifier = "linkedin" + name = "linkedin" + url = "https://www.linkedin.com/in/spencer-powell-pagwin/" [markup] [markup.goldmark] [markup.goldmark.renderer] diff --git a/content/links/index.html b/content/links/index.html new file mode 100644 index 0000000..13dbf7f --- /dev/null +++ b/content/links/index.html @@ -0,0 +1,10 @@ + + + + Github
+ Linkedin
+ blog rss feed
+ back to website homepage
+ sitemap + + diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 523edff..8f16c78 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -4,5 +4,6 @@
rss github + linkedin From ad1452b89a6d1d464c107ec6ac4fc24390a69b7f Mon Sep 17 00:00:00 2001 From: Pagwin Date: Thu, 22 Sep 2022 14:37:32 -0400 Subject: [PATCH 3/6] fixed shitty indent in rut enums article --- content/blog/rust_enums.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/content/blog/rust_enums.md b/content/blog/rust_enums.md index bbdc5d4..7ca9d64 100644 --- a/content/blog/rust_enums.md +++ b/content/blog/rust_enums.md @@ -14,13 +14,13 @@ As the description of this article says I wrote this to try and probably fail to ```dart String anything(Object something) { if(something is bool){ - if(something) return "fizz"; - return "buzz"; + if(something) return "fizz"; + return "buzz"; } if(something is int){ - if(something < 10) return "smol"; - if(something < 20) return "Mcdonald's medium"; - return "LARGE"; + if(something < 10) return "smol"; + if(something < 20) return "Mcdonald's medium"; + return "LARGE"; } return "$something"; } From 49aab065cf0af428c34d94144b4a161122877ce2 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Mon, 10 Oct 2022 17:08:06 -0400 Subject: [PATCH 4/6] wrote out most of a new article --- content/blog/rust_type_hiccups.md | 66 +++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 content/blog/rust_type_hiccups.md diff --git a/content/blog/rust_type_hiccups.md b/content/blog/rust_type_hiccups.md new file mode 100644 index 0000000..766e41d --- /dev/null +++ b/content/blog/rust_type_hiccups.md @@ -0,0 +1,66 @@ +--- + +title: "Rust Type Hiccups" + +description: "A couple of hiccups I've run into with rust's type system" + +date: 2022-10-10 + +draft: true + +--- + +# Rust type hiccups + +This article is the result of running into annoyances in rust's type system. These annoyances aren't bugs as much as they are limitations caused by how rust's type system is currently implemented. Interestingly one these seems relatively easy to fix at first glance while the other is a problem whose root cause(s) have been around for a good few years and probably won't be fixed for at least some ways into the future. + +## Case 1: From\\> for Result\,E\> and vice versa for E + +Did you know that rust didn't have this implemented for you? I certainly didn't until about a week ago when I wanted to convert from a `Result` to a `Result<(),Error>` for the sake of convenience when returning from a function. Now you may think that this is the one which I think is the easy fix but if you thought that you'd be wrong. + +### Why this seems easy + +If you don't know rust or didn't think about this that much yet you may wonder how this is easy. Well to answer that I think I'll just show you the implementation. +```rs +impl ,E> From> for Result { + fn from(val:Result){ + val.map(U::from) + } +} +``` +That's it the entire definition and implementation of what I want in all of 5 lines of code where 2 of them are just curly brackets. So why doesn't that work? + +### The motherf\*cking identity implementation + +Yeah the issue is that rust implements `From for T` so all types can be gotten from themselves. The issue with this is twofold +1. it means that U can be T which means that +2. the implementation we just wrote out before implements `From> for Result` which is the identity which means we have two implementations of a trait on one type which rust doesn't allow. By the way if you want to make an error message more helpful in rust change the error message you get when you try this to point out that the issue is that U can be T. + +### Can we just tell rust to not implement this when U = T? + +Nope not a thing in rust at the moment and I remember(perhaps incorrectly) that [negative bounds](https://github.com/rust-lang/rust/issues/42721) are for traits but not types generally. + +### What about [specialization](https://doc.rust-lang.org/unstable-book/language-features/specialization.html)? + +Nope +1. right now the [current subset of specialization](https://doc.rust-lang.org/unstable-book/language-features/min-specialization.html) that's considered stable doesn't allow for implementation in a case of a generic popping up twice which is the exact issue we have here +2. the identity implementation From has doesn't have the default keyword so if you wanna override it you're sol. + +## So what was the other hiccup? + +Oh yeah there was a separate hiccup. Yeah that hiccup came from me trying to do SI derived units via const generics, my mvp version looked something like this +```rs +struct Measure{ + amount:f64 +} +impl Div> for Measure { + // Don't mind the curly brackets rust compiler wanted me to put them there for whatever reason + type Output = Measure<{km1-km2},{sec1-sec2},{kg1-kg2}>; + fn div(self, rhs: Self) -> Self::Output { + Self::Output{ + amount:self.amount/rhs.amount + } + } +} +``` +and had I not run into my type hiccup Mul would've been implemented in a similar manner and Add and Sub would've been trivial. Alas rust doesn't allow this to compile because `cannot perform const operation using kg1` and so on for all the other const generics... what? What do you mean I can't do a const operation with a const wtf ~~I also got an error that said something about how an associated type wasn't allowed when I set Rhs but shhhhh~~. Yeah in the compiler I imagine that allowing for calculating const generics with values that are const/const generics is relatively easy so I hope that does get improved at some point. From b2feaec5b653c5a3004eae341e36b78c439742f8 Mon Sep 17 00:00:00 2001 From: Pagwin Date: Tue, 20 Dec 2022 23:17:26 -0500 Subject: [PATCH 5/6] grammarly fixes --- content/blog/rust_type_hiccups.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/content/blog/rust_type_hiccups.md b/content/blog/rust_type_hiccups.md index 766e41d..e8b94f2 100644 --- a/content/blog/rust_type_hiccups.md +++ b/content/blog/rust_type_hiccups.md @@ -4,7 +4,7 @@ title: "Rust Type Hiccups" description: "A couple of hiccups I've run into with rust's type system" -date: 2022-10-10 +date: 2022-12-20 draft: true @@ -12,11 +12,11 @@ draft: true # Rust type hiccups -This article is the result of running into annoyances in rust's type system. These annoyances aren't bugs as much as they are limitations caused by how rust's type system is currently implemented. Interestingly one these seems relatively easy to fix at first glance while the other is a problem whose root cause(s) have been around for a good few years and probably won't be fixed for at least some ways into the future. +This article is the result of running into annoyances in rust's type system. These annoyances aren't bugs as much as they are limitations caused by how rust's type system is currently implemented. Interestingly one of these seems relatively easy to fix at first glance while the other is a problem whose root cause(s) have been around for a good few years and probably won't be fixed for at least some ways into the future. ## Case 1: From\\> for Result\,E\> and vice versa for E -Did you know that rust didn't have this implemented for you? I certainly didn't until about a week ago when I wanted to convert from a `Result` to a `Result<(),Error>` for the sake of convenience when returning from a function. Now you may think that this is the one which I think is the easy fix but if you thought that you'd be wrong. +Did you know that rust didn't have this implemented for you? I certainly didn't until about a week ago when I wanted to convert from a `Result` to a `Result<(), Error>` for the sake of convenience when returning from a function. Now you may think that this is the one which I think is the easy fix but if you thought that you'd be wrong. ### Why this seems easy @@ -28,13 +28,13 @@ impl ,E> From> for Result { } } ``` -That's it the entire definition and implementation of what I want in all of 5 lines of code where 2 of them are just curly brackets. So why doesn't that work? +That's it the entire definition and implementation of what I want in just 5 lines of code where 2 of them are just curly brackets. So why doesn't that work? ### The motherf\*cking identity implementation -Yeah the issue is that rust implements `From for T` so all types can be gotten from themselves. The issue with this is twofold +Yeah, the issue is that rust implements `From for T` so all types can be gotten from themselves. The issue with this is twofold 1. it means that U can be T which means that -2. the implementation we just wrote out before implements `From> for Result` which is the identity which means we have two implementations of a trait on one type which rust doesn't allow. By the way if you want to make an error message more helpful in rust change the error message you get when you try this to point out that the issue is that U can be T. +2. the implementation we just wrote out before implements `From> for Result` which is the identity which means we have two implementations of a trait on one type which rust doesn't allow. By the way, if you want to make an error message more helpful in rust change the error message you get when you try this to point out that the issue is that U can be T. ### Can we just tell rust to not implement this when U = T? @@ -44,11 +44,11 @@ Nope not a thing in rust at the moment and I remember(perhaps incorrectly) that Nope 1. right now the [current subset of specialization](https://doc.rust-lang.org/unstable-book/language-features/min-specialization.html) that's considered stable doesn't allow for implementation in a case of a generic popping up twice which is the exact issue we have here -2. the identity implementation From has doesn't have the default keyword so if you wanna override it you're sol. +2. the identity implementation From has doesn't have the default keyword so if you wanna override it you're kinda fucked(unless you're trying to modify the stdlib like I was). ## So what was the other hiccup? -Oh yeah there was a separate hiccup. Yeah that hiccup came from me trying to do SI derived units via const generics, my mvp version looked something like this +Oh yeah, there was a separate hiccup. Yeah that hiccup came from me trying to do SI-derived units via const generics, my minimum viable product version looked something like this ```rs struct Measure{ amount:f64 @@ -58,9 +58,9 @@ impl; fn div(self, rhs: Self) -> Self::Output { Self::Output{ - amount:self.amount/rhs.amount + amount: self.amount/rhs.amount } } } ``` -and had I not run into my type hiccup Mul would've been implemented in a similar manner and Add and Sub would've been trivial. Alas rust doesn't allow this to compile because `cannot perform const operation using kg1` and so on for all the other const generics... what? What do you mean I can't do a const operation with a const wtf ~~I also got an error that said something about how an associated type wasn't allowed when I set Rhs but shhhhh~~. Yeah in the compiler I imagine that allowing for calculating const generics with values that are const/const generics is relatively easy so I hope that does get improved at some point. +and had I not run into my type hiccup Mul would've been implemented similarly and Add and Sub would've been trivial. Alas, rust doesn't allow this to compile because `cannot perform const operation using kg1` and so on for all the other const generics... what? What do you mean I can't do a const operation with a const wtf ~~I also got an error that said something about how an associated type wasn't allowed when I set Rhs but shhhhh~~. Yeah in the compiler I imagine that allowing for calculating const generics with values that are const/const generics is relatively easy so I hope that does get improved at some point. From 30f5225002235bed2e4d4877fc71dd6bf4925fec Mon Sep 17 00:00:00 2001 From: Pagwin Date: Tue, 20 Dec 2022 23:23:12 -0500 Subject: [PATCH 6/6] changed article to not draft and added a conclusion --- content/blog/rust_type_hiccups.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/content/blog/rust_type_hiccups.md b/content/blog/rust_type_hiccups.md index e8b94f2..4c4431b 100644 --- a/content/blog/rust_type_hiccups.md +++ b/content/blog/rust_type_hiccups.md @@ -6,7 +6,7 @@ description: "A couple of hiccups I've run into with rust's type system" date: 2022-12-20 -draft: true +draft: false --- @@ -64,3 +64,7 @@ impl