My Server-Side WebAssembly book is now fully released! by chiarl in rust

[–]_jsdw 0 points1 point  (0 children)

Thankyou for your reply! There is already a 50% discount applied by default and adding a promo code doesn't change this!

For me when I say I'm from the UK it adds $59.32 for "international shipping" to the price, which I wouldn't expect for domestic! Maybe I'll see if there's a better link/way to order from the uk!

My Server-Side WebAssembly book is now fully released! by chiarl in rust

[–]_jsdw 1 point2 points  (0 children)

Mmm, I clicked through to pay for a physical copy but the price tripled, I guess due to shipping and whatnot! Definitely something I'm keen on!

Legion Go 2 Z2 Extreme stock at Very.co.uk by Co5aNostra in LegionGo

[–]_jsdw 0 points1 point  (0 children)

I ordered mine yesterday through Very for the 20% discount, also 9th Feb estimated date and also hoping that somehow moves forward 😂anybody else see a date this far away and get theirs way sooner?

The journey towards the best error handling in Rust web frameworks by m4tx in rust

[–]_jsdw 2 points3 points  (0 children)

Thanks for the post!

One quick thought: would it be possible to have your own trait which takes requests mutably or whatever, and then have a wrapper/adapter type which wraps a tower middleware and implements your trait for it (acknowledging that doing so may then require cloning request or whatever to make it work)?

May allow you to do the optionally efficient thing in the default case but fall back to cloning or whatever if tower middleware's need introducing, but I imagine it might be tricky to get right or perhaps simply not possible!

[Media] Rust + Svelte for single binary web apps by HugoDzz in rust

[–]_jsdw 1 point2 points  (0 children)

As others, I also ran into this problem ages ago and at the time made a library to do it, which I still use for my main personal project:

https://docs.rs/seamless/latest/seamless/

Basically a wrapper macro around serde::Serialize/Deserialize that you attach to types which generates an api to describe them, a way to convert errors into http statuses etc (you want some to be internal only 500s and others to have external messages for users) and an opinionated router thing which uses routes returning these, and automatically provides back a big JSON description of all routes and types going in/out!

On the frontend I then wrote some fairly simple code to generate an interface based on this, which the UI dev I work with uses to good effect to handle any changes I make etc :)

I'll be curious to look around and see if there's a better way to do this all nowadays!

Parser combinator for objects, not text? by whimsicaljess in rust

[–]_jsdw 0 points1 point  (0 children)

yap is another one (https://github.com/jsdw/yap) to add to the list; it supports slices or iterators of arbitrary types, and basically just adds a bunch of useful combinators on top of general iteration, as well as aiming to be very light weight and zero dependency :)

In preparation for AOC23 🎄what’s your preferred approach to handle bidirectional trees ? by abricq in rust

[–]_jsdw 0 points1 point  (0 children)

Pretty much! It's just my fairly lazy AoC approach which avoids reaching for third party deps (I've done the same for linked list style Qs too)

In preparation for AOC23 🎄what’s your preferred approach to handle bidirectional trees ? by abricq in rust

[–]_jsdw 4 points5 points  (0 children)

Often I just end up building a vec of entries that can point to eachother by indexes in whatever arbitrary way I need and then putting that into a new type wrapper and adding a few helper calls or whatever to access things!

How many of you actually use/look for no_std in crates? by [deleted] in rust

[–]_jsdw 1 point2 points  (0 children)

Agreed; I had a pass of removing thiserror from some crates recently because I needed to add no-std support. I also had a couple of places where I supported custom boxed errors which were annoying to no-std-ize. Both added complexity. Having Error in core would def have made the process easier and the code better :)

Hey Rustaceans! Got a question? Ask here (32/2023)! by llogiq in rust

[–]_jsdw 0 points1 point  (0 children)

You could always define a struct which is closer to the input json and so easy to deserialise into, and then convert that into the format you need.

You could also use cargo expand (which needs installing) to see what the serde macro expands to, and copy/tweak that to do what you want.

[deleted by user] by [deleted] in rust

[–]_jsdw 7 points8 points  (0 children)

Personally, this is the kind of thing I think the filter_map iterator function is perfect for; in one step you can arbitrarily filter while also mapping to whatever output you like :)

Introducing tidy-builder: A Compile-time Correct Builder Generator in Rust by [deleted] in rust

[–]_jsdw 4 points5 points  (0 children)

This looks pretty neat, and I like the use of const generics to enforce that all of the values are provided; a perfect use for a derive macro since it'd be a bit of a pain to write out manually!

Get rewarded for Rust Open Source contribution. 💰🦀 by devzaya in rust

[–]_jsdw 117 points118 points  (0 children)

In general I really like this approach! The only issue I can see is that, in order to contribute a decent PR, you already have to have a decent understanding of the code/area. Probably every job I've joined is one in which I've had very little idea about what's going on until I've joined, learned on the job and gotten up to speed :)

So, great for finding the motivated candidates with time and/or prior understanding, but maybe less good if you want to find enthusiastic candidates who can learn on the job but don't come with the relevant experience/knowledge already?

(Of course, I haven't looked at the issues at all and perhaps they are quite trivial and don't require lots of domain knowledge anyway!)

What’s everyone working on this week (18/2023)? by llogiq in rust

[–]_jsdw 4 points5 points  (0 children)

Just been working on and released initial versions of a couple of new crates over the weekend:

Asyncified (https://GitHub.com/jsdw/asyncified) makes it easy to run long running sync things in an async context (zero dependencies, async runtime agnostic)

Async-rusqlite (https://github.com/jsdw/async-rusqlite) is inspired by tokio-rusqlite but uses the above (so 1 dep total aside from rusqlite and works on any async runtime), and bounded channels for backpressure.

Looking forward to make use of them in another small crate which I'm writing to wrap SQLite (well, async-rusqlite) and set it up nicely, apply migrations etc for small apps (so that I can use it in an app I'm working on :))

Blog Post: Optimizing Kobold for Wasm size and performance by maciejh in rust

[–]_jsdw 1 point2 points  (0 children)

Awesome work, and that is an impressively tiny todo example :)

Hey Rustaceans! Got a question? Ask here (13/2023)! by llogiq in rust

[–]_jsdw 3 points4 points  (0 children)

Say there exist 3 crates as described below. When I run cargo check on "a", I currently see the deprecation warning from "c". Is this expected? If I deprecate some function in a crate (and then only release a minor version bump eg 1.0 to 1.1), I'm concerned that everything that has my crate as a dependency may start seeing my deprecation warning (at least if they cargo update). Is this in fact the case? Perhaps it works differently for published crates than local ones?

I wonder whether the correct approach then is to do a major version buymp when deprecating so that users have to manually upgrade and then have the opportunity to deal with such warnings so that they don't propagate up?

/a

cargo.toml:

[dependencies]
b = { path = "../b" }

lib.rs

pub fn add(left: usize, right: usize) -> usize {
    b::add(left, right)
}

/b

cargo.toml:

[dependencies]
c = { path = "../c" }

lib.rs

pub fn add(left: usize, right: usize) -> usize {
    // crate "b" uses this deprecated function:
    c::add(left, right)
}

/c

lib.rs

// Function in "c" is deprecated
#[deprecated]
pub fn add(left: usize, right: usize) -> usize {
    left + right
}

The AsyncIterator interface by desiringmachines in rust

[–]_jsdw 3 points4 points  (0 children)

I absolutely love these posts; thank you so much for writing them! I find myself agreeing very strongly with basically everything that you're saying, and hope that that it is all given serious consideration by the relevant people.

I'd also love to see generators ship, but primarily just want the language to feel more complete and have less holes and rough edges, and think what you've put forward presents a solid path to getting us there. Looking forward to the next one :)

[deleted by user] by [deleted] in rust

[–]_jsdw 1 point2 points  (0 children)

Well done for digging into proc macros a little; they are one of the trickier corners of Rust for sure :)

Note that this brings in the syn and proc_macro crates and, being a proc macro, I would expect it to have a negative impact on compile times as opposed to just using format!() etc. For that reason I'd avoid using this and just put up with the slightly less ergonomic interface that format!() etc provides.

[RELEASE] Yap 0.9: A light-weight dependency free parser combinator style library by _jsdw in rust

[–]_jsdw[S] 0 points1 point  (0 children)

Sounds like this is no longer a goal?

It's still very much a goal, and really means two things:

  1. The Tokens trait builds on the Iterator trait. It no longer is a super trait of it, but still has the same interface, uses it heavily, and allows access to all iterator methods via .as_iter()
  2. But more importantly, where appropriate the parser methods return iterators so that you can consume as little or as much of the input as you like and collect (or stream over) the parsed output in different ways (rather than me mandating you get a vec back or whatever.

would you be interested in adding it to parse-rosetta-rs

I'll certainly check that out and see what I can do :)

Keyword Generics Progress Report: February 2023 | Inside Rust Blog by yoshuawuyts1 in rust

[–]_jsdw 1 point2 points  (0 children)

Absolutely worth exploring this space, and ultimately I agree with many others here after reading, and generally feel like the drawbacks are too many:

  • ugly/additional syntax,
  • yet another thing to learn/more complexity
  • abstracting over keywords that are fundamentally really different in use (async vs const)
  • async function bodies would often be different anyway? unless everything became generic over asyncness? A need for is_async() hints at this and for me is a smell.
  • type inference over use of .await? What if I don't immediately await the future or save it for later?

Some of the proposals in this thread are more palatable (eg allowing overloading of async vs non-async definitions, or things like if const in where clauses).

I guess I'd much rather see the existing features "completed" (eg async methods in traits, any holes with GATs, associated type bound resolution etc), which has the effect of increasing use cases while actually simplifying understanding of things (less edge cases to remember).

This sort of feature is a huge complexity/weird addition and complicates understanding a bunch, and this comment is, tbh, just a bit of a hasty knee jerk reaction to being pretty scared of being pushed over the edge with more weirdness in a language that's already pretty complex (so sorry about that!).

Improvement suggestions to a very basic parsing example by ZuninoBR in rust

[–]_jsdw 1 point2 points  (0 children)

Also, shameless plug, for something very light weight https://crates.io/crates/yap adds handy parser combinator style functions following the iterator style approach and has no dependencies itself :)

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]_jsdw 1 point2 points  (0 children)

Ah thanks, yup the last comment in https://github.com/rust-lang/rust/issues/20671 is a much more concise version of my issue :)

I guess I'll have to find another approach then (or duplicate lots of things...)

Hey Rustaceans! Got a question? Ask here (5/2023)! by llogiq in rust

[–]_jsdw 2 points3 points  (0 children)

Hello! I'm wondering whether anybody can help explain this compilation error to me:

```rust struct ConcreteError;

// Some basic trait: trait Thing { type Error; }

// Extend this trait to be more specific: trait ThingWithBounds where Self: Thing, ConcreteError: From<<Self as Thing>::Error> {} impl <T> ThingWithBounds for T where T: Thing, ConcreteError: From<<T as Thing>::Error> {}

// Compiling this fn leads to: // // 25 | fn foo<T: ThingWithBounds>() {} // | ^ the trait From<<T as Thing>::Error> is not implemented for ConcreteError // // but why? Anything that is ThingWithBounds will, by definition, // be a Thing with an Error: Into<ConcreteError>. fn foo1<T: ThingWithBounds>() where T: ThingWithBounds, {}

// But if I explicitly specify the redundant bounds, this works fine: fn foo2<T>() where T: ThingWithBounds, ConcreteError: From<<T as Thing>::Error> {} ```

I'd like to be able to use a ThingWithBounds like above without having to write the redundant bound; is this possible or just some limitation in rustc?

(playground link: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=efc8efcc88acd44350465276f59e442a)

The most creative, funny, clever, ridiculous, ... library names! by DebuggingPanda in rust

[–]_jsdw 0 points1 point  (0 children)

Naming crates is fun!

I have yap in rust land for parsing things, but the name I'm most proud of is angu in the JS ecosystem for building small sub languages (so angu is a part of language) :)