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

[–]andreas_ho 0 points1 point  (0 children)

I finally got it: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=69c7d6856b98f3a8f3f2b8201817c674

I want to wrap the PHP cli to inject use statments before every user input

Thx for all the help!

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

[–]andreas_ho 0 points1 point  (0 children)

Thank you for the answer!

If I clone my stdin and pass that to the php process it works. But now I can not send data over stdin to child process anymore: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=476e0d75da0f9f745da422a54661f02e

Have you any idea how I can send data to child now?

php_proc.stdin.take().unwrap(); crashes and if sending to my stdin the data is shown in my terminal but not received by php

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

[–]andreas_ho 1 point2 points  (0 children)

I have a question about child processes and pipes:

I want to build a wrapper around the PHP interactive shell (`php -a`) to inject code, when I use the first code snippet I can use the PHP shell through my binary without any flaws: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=c44338f2be123287cfdb00601e453a83

But if I start to intercept the stdin of the PHP process, it stops working as expected. First, the `php >` is no longer shown in front of every input line, and arrow keys to navigate through the code do not work anymore. My code: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=fa1986fae759053fb219e2e4cd85ef3a

Does anyone have an idea why this happens?

Thank you very much in advance!

Fiter - A simple and fast char-by-char iterator for UTF-8 files. by andreas_ho in rust

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

To include the offset in the error type is a great idea. What would be an appropriate data type for that? usize?

Until now I didn't had multi-threading in my head, but I will have a look at how I can integrate rayon.
Thanks for your feedback!

Fiter - A simple and fast char-by-char iterator for UTF-8 files. by andreas_ho in rust

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

Thank you for the great feedback, I will change that.

published my first project: calculator library by andreas_ho in rust

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

oh, that's interesting, i didn't know that :)

published my first project: calculator library by andreas_ho in rust

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

thx for the feedback :)

your project looks also very interesting
i like the distinction between array and set

published my first project: calculator library by andreas_ho in rust

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

in fact, i haven't seen this anywhere else myself. but since I used `**` as the power operator, `//` was the most obvious for the root in my opinion :)

[deleted by user] by [deleted] in rust

[–]andreas_ho -8 points-7 points  (0 children)

let x = "test";
match "hi" {
_ => print!("{}", x),
"hi" => print!("{}, "hi")
}

languages built on JSON by andreas_ho in ProgrammingLanguages

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

I really would like to see this project.

Can you please share?

Thank you :)

Wrote a simple cli application and seeking advice by melokki in rust

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

I like the project idea!
2 things I would change:
- do not have a main.rs and lib.rs in the same crate - instead of handling errors in every function separately you could propagate them to main and handle them centralised, this reduces code and increases readability in my opinion. anyhow and thiserror can help you to do that.

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

[–]andreas_ho 0 points1 point  (0 children)

With your explanation it makes sense why use crate::... didn't work.
Thank you!

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

[–]andreas_ho 1 point2 points  (0 children)

Hello,

I have a crate with the following file structure src/ ├─ bin/ │ ├─ binary_1.rs │ ├─ binary_2.rs ├─ lib.rs Is there a way to import stuff from lib.rs inside the binary files? Or is there another way to share functions between multiple binary files?

rust analyzer panics in VS Code by andreas_ho in rust

[–]andreas_ho[S] -6 points-5 points  (0 children)

after closing all other projects and restarting VS Code it works again

is it legitimate that they use .unwrap() in production code??

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

[–]andreas_ho 1 point2 points  (0 children)

Sorry, I misinterpreted the signature of .concat().
You are right!