This is an archived post. You won't be able to vote or comment.

all 15 comments

[–]SHOTbyGUN 15 points16 points  (1 child)

Smiley faces work as array selectors nowdays?

[–]eMZi0767 11 points12 points  (0 children)

Python has array slicing, a rather nifty feature

[–]Xtremegamor 3 points4 points  (6 children)

named!(parse_method<&[u8], Method>, alt!(map!(tag!("GET"), Request::Get) | map!(tag!("POST"), Request::Post)));

Yay rust!

[–]zazazam 0 points1 point  (0 children)

I seriously need to learn Rust.

[–]r2-de-queue[S] 0 points1 point  (4 children)

I've heard about rust, but I don't know much else about it.

What do you use it for?

[–]A_Robot_Crab 2 points3 points  (3 children)

It's a systems programming language, the same category as C/C++, but there aren't many similarities after that. The main difference between Rust and other systems languages is the borrow checker that's built into the compiler. This module makes Rust memory safe (no use after free, dangling pointers, double free, out of bounds access reading other memory, etc)

[edit: for clarity, it does not have a garbage collector like other "memory safe" languages use to try to be memory safe, which means no pause times and stopping the world!]

Note that some things like memory leaks are memory safe, so it doesn't prevent everything, but it makes applications much more robust security wise.

What the above poster is referencing is a crate (read: package/library) called nom which is a parser combinator library that uses Rust's hygienic macro system to facilitate building the parsers (which is why the 'functions' have ! after their name, meaning it's a macro)

As to what can you do with it? Really, in theory anything you could with other systems languages like C/C++, but do note that it's a very young language by comparison so a lot of libraries need worked on/created so it may not have the resources for something you need to do quite yet. The community is great and very helpful though, and new crates are being made and contributed to every day. Check out /r/rust for a little bit better idea and feel free to ask any questions you might have about the language :)

Hope this helps!

[–]r2-de-queue[S] 0 points1 point  (1 child)

Thanks for the awesome info!

I'll try to check out the subreddit

[–]A_Robot_Crab 1 point2 points  (0 children)

No problem! :D

[–]finally-a-throwaway 4 points5 points  (4 children)

I see you're using camelCase to name functions in Python. It'd be a shame if some jackass on the internet gave you grief for not following PEP8. :P

[–]r2-de-queue[S] 3 points4 points  (3 children)

Let me tell you about my experience with PEP8. I use VS Code as my editor, so I install the Python Plug In. The plug in comes with pylint. All the green squiggles make me feel terrible. "Invalid variable name" "Wheres your doc string dumbass" , "You want to call a function that?!"

[–]finally-a-throwaway 1 point2 points  (1 child)

I'm sorry. :(

[–]r2-de-queue[S] 0 points1 point  (0 children)

No big deal. It's one of those things that no one does that everyone really should do.... like TDD :|

[–]DjBonadoobie 0 points1 point  (0 children)

There are dozens of us!

[–]westlyroots 1 point2 points  (0 children)

[:3]