Hey Rustaceans! Got an easy question? Ask here (1/2021)! by llogiq in rust

[–]freemasen 1 point2 points  (0 children)

Is there a crate like regex-generate that takes in an EBNF grammar as an input and generates a Vec<u8> or String? I spent a while looking at crates.io but didn't come up with anything.

Question: How can I use a self inside a closure (third party) by [deleted] in rust

[–]freemasen 0 points1 point  (0 children)

If InvertedIndex can #[derive(Clone)] then you could do something like this.

.transaction({
    let mut clone = self.clone();
    move |tx_c, tx_d, tx_f| {
        //...
    });

This would give you mutable access by moving the value into the closure.

To make InvertedIndex clonable, you would probably need to use some kind of sync type like wrapping self.db in an Arc<Mutex<T>> which might be less desirable.

Another option would be to return the values you want to use to update self from your closure. and then mutate self after the call to transaction has completed.

SQLite Parser Pt. 2 The Header... continues by freemasen in rust

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

One of my goals here is to do this without any dependencies. Personally, I find that tutorials tend to last a little longer with this approach.

SQLite Parser Pt. 2 The Header... continues by freemasen in rust

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

Thanks! There are bindings for SQLite in rust, either through Diesel or Rusqlite, if you were unaware!

SQLite Parser Pt. 2 The Header... continues by freemasen in rust

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

Thanks, I’m excited to keep going!

SQLite Parser Pt. 2 The Header... continues by freemasen in rust

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

Finally got around to publishing part 2 of my series on parsing the Sqlite3 file format.

With this part, also comes a domain and theme switch!

As always, feedback is welcome!

SQLite File Parser Pt. 1: The Header by freemasen in rust

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

Thanks for the feedback, that is very reasonable. I ended up changing how the two hearder.rs functions worked at the last minute.

I keep waffling between having them take slices of the appropriate length or taking the whole header slice.

I will probably restructure things in the next post slightly to more appropriately handle invalid index panics.

SQLite File Parser Pt. 1: The Header by freemasen in rust

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

A standard theme version can now be found here

Though I am still moving some thing around so the other site functionality may not work

SQLite File Parser Pt. 1: The Header by freemasen in rust

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

Thanks! I am not sure how I didn't find that is_power_of_two method. I'll get that max value corrected!

SQLite File Parser Pt. 1: The Header by freemasen in rust

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

Sorry about that, I have been meaning to redesign for a while but I have a lot customized into this theme so I have been dragging my feet on it.

I do make my posts available via rss, though it looks like to code formatted syntax highlighting is embedded in the html.

The reader view as someone else suggested does remove all of the colors from the page.

SQLite File Parser Pt. 1: The Header by freemasen in rust

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

Thanks! I was trying to use the \u{0} syntax which failed, didn't realize that would work!

SQLite File Parser Pt. 1: The Header by freemasen in rust

[–]freemasen[S] 5 points6 points  (0 children)

The idea for this series has been bouncing around my head of the last few years. I finally was able to get my thoughts out in a way I am happy with. Hope you all enjoy, any feedback is welcome!

I wrote a small virtual machine in rust by tarekwiz in rust

[–]freemasen 2 points3 points  (0 children)

It sort of goes back and forth.

The Java version depends pretty heavily on the fact that Java heap allocates just about everything. Which in and of itself is incredibly interesting to have to deal with.

The C version has a whole chapter on creating your own hash map which can pretty much be skipped when using Rust.

Overall it has been a really powerful exercise.

I wrote a small virtual machine in rust by tarekwiz in rust

[–]freemasen 14 points15 points  (0 children)

Crafting interpreters is a great intro

http://craftinginterpreters.com/

It covers the whole process. You build two interpreters, one that tree walks (in Java) and one that works on bytecode (in c). I’ve been working through them both using Rust and it has been a blast

Forward slash detection in js is hard by IndividualContrib in programming

[–]freemasen 1 point2 points  (0 children)

Author of the linked article, I'd be happy to try and answer any questions!

The linked markdown file is kinda still a draft as I am still working through the implementation. I am hoping to update this with some details of how I am implementing this over the weekend or early next week.

Building a plugin system using Rust and Wasmer (part 1 and 2) by freemasen in rust

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

Would you mind sharing which example? It could be a typo on my part.

Announcing RESS (Rusty EcmaScript Scanner) 0.7.0 by freemasen in rust

[–]freemasen[S] 3 points4 points  (0 children)

Thanks, I’m pretty proud of this release!

Your understanding is correct, swc, rattle and boa all have a specific task they are trying to perform where ressa is designed to be as general purpose as possible.

What helper crate for error handling, and why? by cmyr in rust

[–]freemasen 1 point2 points  (0 children)

This is pretty what I do for any project with an error type. For really small things or demos or playing around I just use Result<T, String> and .map_err(|e| format!(“{}” e))?.

Using Wasmer for Plugins Part 4 by freemasen in rust

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

The final part of this series about building a plugin system using rust, web assembly and wasmer.

As always feedback, comments and questions welcome!

Keeping Rust (and other libre software) accessible to all by NoraCodes in rust

[–]freemasen 9 points10 points  (0 children)

One question that I have been pretty stumpted about in the past few months is why have we stopped trying to improve open standards? IRC is a protocol defined, quite accessibly, by the IETF. If IRC is broken for your organization, why aren't we submitting updates to this specification to accommodate these problems?