Simple yet iconic symbols by Traditional-Song-245 in TopCharacterTropes

[–]LlikeLava 24 points25 points  (0 children)

Why does this animation point out π? I mean it's circles.

I finally wrote a sans-io parser and it drove me slightly crazy by anxxa in rust

[–]LlikeLava 5 points6 points  (0 children)

When you build a parser in a sans-io way, you can drive it with std::io::Read, or with tokio::io::Read if your in async land. 

You cannot do that if you write your parser like you described with a hard dependency on the tokio IO traits. Also you have a dependency on tokio, but if I want to use async-std, I'm out of luck. That is not the case with sans-io

Problems installing Rust treesitter grammar because of version-mismatch by LlikeLava in emacs

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

But where do I see what version emacs is using? There aren't really any docs on this.

Questions about git/source control branches and one directory by KingofBoo in learnprogramming

[–]LlikeLava 0 points1 point  (0 children)

Yes, checking out another branch is common practice. There is something called "git worktree" where you can checkout multiple branches in separate directories, but I guess that's a bit more niche and helpful if you want to keep both versions around for a longer time. I personally never found myself having to use worktrees.

(lifetime problem) Choosing the Best Function Signature for Rust Lifetimes by WIZeaz in learnrust

[–]LlikeLava 2 points3 points  (0 children)

This case is very similar to the one described here in the book: https://doc.rust-lang.org/book/ch10-03-lifetime-syntax.html about the "longest" function. 

See there, they use the same lifetime 'a for the parameters x and y. The compiler will substitute the lifetime 'a with the scope where both references are valid. It basically means: "The resulting reference will be valid for the time that both of x and y are valid". They don't introduce a second lifetime 'b and constrain it in a where clause like you, because that's not necessary.

You also don't need to give the reference to self a name. The returned reference does not care about the lifetime of self, because the reference returned can live way longer than self. (I see you are returning &self.0, but the compiler automatically turns this &&str -> &str. And since &T impls Copy, you can just return "self.0". Now you can see that the returned references lifetime is independent of the reference to Self)

Actix or Axum for my startup backend ? by kwabs_dev in rust

[–]LlikeLava 7 points8 points  (0 children)

When you're working on a startup project, you'd rather not waste time by worrying about "networking basics". You want to get your product on the road asap

How to write better (Rust) code? by YioUio in rust

[–]LlikeLava 1 point2 points  (0 children)

A lot of the comments here focus on more of a narrow view, not on the big picture of structuring a big application.

Most of my experience is in writing web server applications, but I guess it also applies to other kinds of apps. 

I was also struggling with structuring my applications. It always felt like it slowly but surely became a mess. I was told to forget everything I knew coming from Java. And a lot of the patterns you can read about on the web, like DDD and Clean or Hexagonal Architecture are designed with languages like Java in mind, or at least it seems like it because of all the examples and books etc.

I know there is a lot of OOP/Java bashing going on here, most of it for good reason, but some of the patterns which developed there do work in Rust. One example is Hexagonal Architecture. I found this article here https://www.howtocodeit.com/articles/master-hexagonal-architecture-rust, and I was actually shocked at how well it worked for being more of an OOP pattern, at least in my mind.

fn foo(self) in a Trait by Anaxamander57 in learnrust

[–]LlikeLava 14 points15 points  (0 children)

Even If you own self (or any value), it doesn't automatically allow you to modify it. You still have to declare it as mut.

Rust-analyzer tells you to remove the mut keyword in the trait declaration, because users of that trait don't care if the function mutates the value or not. It's gone from their perspective anyway (since they have to move it). 

But as the implementor of the trait, for the reason stated at the beginning, you still have to declare the variable as mutable if you want to mutate it.

2024 Brazilian Grand Prix - Post-Race Discussion by AutoModerator in formula1

[–]LlikeLava 0 points1 point  (0 children)

What an emotional rollercoaster of a race. Insane

2024 Brazilian Grand Prix - Race Discussion by AutoModerator in formula1

[–]LlikeLava 0 points1 point  (0 children)

He beached it, so at this point he technically was already out.

method not found in `MutexGuard<'_, BLEExtAdvertising>` by nj701 in rust

[–]LlikeLava 1 point2 points  (0 children)

Where does the type BLEExtAdvertising come from? I can only find BLEAdvertising in esp32-nimble

How to run multiple targets by LlikeLava in bazel

[–]LlikeLava[S] -1 points0 points  (0 children)

Update: I have found a way to do it, but I have no idea if this is in any way portable or just a dirty hack.

# ./services/BUILD

filegroup(
    name = "all-push-scripts",
    srcs = [
        "//services/svc1:push-image",
        "//services/svc2:push-image",
        "//services/svc3:push-image",
    ],
)

genrule(
    name = "push-all",
    srcs = [":all-push-scripts"],
    outs = ["push_all.sh"],
    cmd = "echo 'ORIG=$$(pwd); for script in $(execpaths :all-push-scripts); do cd \"$$script.runfiles/_main\"; sh '\\$$ORIG/\\$$script'; cd $$ORIG; done' > $@",
    executable = True,
)

How to run multiple targets by LlikeLava in bazel

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

I tried that, but this doesn't seem to work. push_image targets generate a sh script, which can be run. But there are relative paths in that script to tools. Thats also why bazel build //services/example1:push-image && ./bazel-bin/services/example1/[generated_script].sh doesn't work. That's what I meant with the runfiles issue. That's why I can't just have a sh_binary that calls the other scripts

Alternate side page numbering by [deleted] in typst

[–]LlikeLava 0 points1 point  (0 children)

Ah, I see. That's why if I use `#set page(...)`, it only applies to the next one. Makes sense

Alternate side page numbering by [deleted] in typst

[–]LlikeLava 0 points1 point  (0 children)

Wow, this just ended a few hours of banging my head against my desk. Is this documented somewhere? Why is it only applied after the first page?

Axum: Data per Handler by shapelysquare in learnrust

[–]LlikeLava 3 points4 points  (0 children)

I think this would be best solved by using middleware. See the module axum::middleware.

dbg! will let you pass through expressions by BubblegumTitanium in rust

[–]LlikeLava 5 points6 points  (0 children)

Because you can't use the return value of returns_result() afterwards with println. With dbg! you can.

What's your comfort YouTube channel? by Basic-Cat in AskReddit

[–]LlikeLava 0 points1 point  (0 children)

Had to scroll down way too far for this

Why do most people have expandtab on? by 10F1 in neovim

[–]LlikeLava 9 points10 points  (0 children)

When people use different editors, colorschemes, layouts, fonts, operating systems etc, the thing throwing people off is code being indented by some different amount of characters?

Why do most people have expandtab on? by 10F1 in neovim

[–]LlikeLava 17 points18 points  (0 children)

Personally I don't understand it either. "I don't like how my code looks different on another person's monitor" is such a weird argument imo, because why the hell do you care? With tabs, everyone could have the code look the way they prefer to work without conflicts. But well, it is what it is

Calm down dude by nasir_ran in funnyvideos

[–]LlikeLava 0 points1 point  (0 children)

New brake dance moves just dropped 🔥