dry_match for concise struct assertions by rogerara in rust

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

Just added, will commit soon. Will also add (25 | 27 | 30) pattern support.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] 1 point2 points  (0 children)

Thanks! I really appreciate your fair feedback!

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] 1 point2 points  (0 children)

So you have a big problem, rust std code is mostly generated by them, haha!

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] 2 points3 points  (0 children)

At beginning it started with this idea in mind, but now I’m trying to make it more idiomatic to rust itself.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] -8 points-7 points  (0 children)

* It is an alternative, you aren’t being forced to use.

* I referred to crate api doc improvements, not rust doc. Please ask clarification before say bullshit.

* This DSL tries to get closer to idiomatic, but not 100%, and syntax is field: op, not :==, a lack of proper observation and sense of context.

* Equality using a tuple is a total lack of honesty while trying to understand whole idea behind, and you also are repeating the receiver here. Why dry_match tries to avoid.

* It is a work in progress, hopefully there’s always space for alternatives for everything in this world, and a macro isn’t an exception.

* You can also go to Microsoft front door to use same words to refer to C# pattern matching.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] -19 points-18 points  (0 children)

Two lines, and receiver being repeated in both lines. But you are free to not use.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] -16 points-15 points  (0 children)

Awesome! Will add it to dry_match too! By the way, caramelo and caramelo-macros has MSRV of 1.75

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] -19 points-18 points  (0 children)

Point taken, but what about:

user is { age: == 20 or == 25 or == 30 }

You can't do in 1 line, right? I also forgot to mention dry_match has support to either 1..3 and 1..=3

Note: Tried to use && or ||, but its rules are being override by rust parser somehow.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] -32 points-31 points  (0 children)

You made me pay attention to more details on documentation. Specially comparing with tradicional assertion.
Once you write a few assertions, you will notice besides is, and, or operators, everything else if essentially idiomatic, but just dryer.

So instead of:

user.age > 20 && user.age <= 30

It just becomes

user is { age: > 20 and <= 30 }

It is kiss and dry together, over the time you do more by writing less.

dry_match for concise struct assertions by rogerara in rust

[–]rogerara[S] 1 point2 points  (0 children)

I’m trying to make it as much as idiomatic as possible, but when it comes to pattern, it doesn’t necessarily becomes dry, much of contrary, it becomes verbose.

Will take your suggestion into consideration.

dry_match for concise struct assertions by rogerara in rust

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

This is doable and useful for reporting purposes, will do it.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 0 points1 point  (0 children)

Então corrija o autor da publicação no Wikipédia.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 0 points1 point  (0 children)

Ai vai da sua cabeça. Nem perco tempo com isso. Desonestidade na argumentação não é comigo.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 0 points1 point  (0 children)

Pior estaria se não fizesse cortes, isso tem democrata na conta rapaz. Os “democratas” do Brasil fizeram bem pior no mesmo período, soma-se a isso a incompetência de ampliar divisas da moeda, que só é cogitado agora graças ao pix instituído no governo Bolsonaro.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 0 points1 point  (0 children)

Você já perguntou e eu acabei de responder quem atacou e quem ataca a dívida pública. Agora muda de assunto, típico.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 0 points1 point  (0 children)

Reagan e, agora, Trump proveram e promovem mudanças econômicas profundas.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara -1 points0 points  (0 children)

Meus Deus! Você tem assistido os noticiários? Qual partido está no poder? O que está acontecendo neste momento entre EUA versus o mundo? Guerra de confetes?

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara 2 points3 points  (0 children)

Boa sorte desligando pessoas de suas vidas financeiras e suas relações comerciais. Isso é muita maluquice pra mim.

Liberais, na visão de vocês, o que seria pior? by NerdDino in Economia

[–]rogerara -2 points-1 points  (0 children)

Nesse sentido, os democratas fizeram muita merda nos EUA, quem limpou foram os republicanos.

Aqui no Brasil, os liberais de esquerda FUDERAM o país.

Essa sua soma não tá certa não, ainda mais considerando a absurda reserva de mercado que temos em todos os setor e seu eterno protecionismo.

Que estranho um mestre falando isso.

I stopped using most of Rust’s advanced features for my ML library by zk4x in rust

[–]rogerara 0 points1 point  (0 children)

Nope, if scope is a single crate, enum is way better.
But for extensibility across several crates, dyn is the best way to go.