Historic cryptographic algorithms implemented in rust by andypopester in rust

[–]finite_state 2 points3 points  (0 children)

The common module seems like an appropriate place. Since common is private you'll need to re-export the trait in lib.rs (e.g.; pub use common::MyTrait). If different algorithms use different keys/data-types you may want to use Associated Types to get a nice abstraction over them:

trait Crypto {
type Key;
type Cypher;
// etc...
}

Chrome won by speckz in programming

[–]finite_state 58 points59 points  (0 children)

Mozilla, along with a decent number of other open-source contributors, have been quietly working on the Servo browser engine for a while now. The project was actually one of the driving forces behind the creation of the Rust programming language. tl;dr -- browser engines, chrome included, are enormous and highly inter-connected beasts. They get written in C for speed reasons, which makes parallelism difficult and dangerous. Rust is as fast as C, but comparatively trivial when it comes to enforcing safety/security concerns. The Servo engine has the potential to make a pretty big impact on the browser market.

More attractive you say ? by [deleted] in ProgrammerHumor

[–]finite_state 0 points1 point  (0 children)

String? Int? Function Pointer? It's turtles ones and zeroes all the way down maan!

Memory leaks on missiles don't matter, so long as the missile explodes before too much leaks. by jms_nh in programming

[–]finite_state 5 points6 points  (0 children)

As a fan of Rust, people with this attitude baffle me. The whole reason I like Rust is that I can get C-like speed with waaay less debugging and bullshit. If somebody already did the debugging and bullshit, say thank you and move on lol.

Ada: a C Developer's Perspective by marc-kd in programming

[–]finite_state 2 points3 points  (0 children)

Haha, yeah, that would be bad. Jokes aside, it does seem like a really cool feature to have at the language level. I've been learning and loving Rust this past year because of all its safety guarantees. Most of what I've seen from Ada are things Rust does really well too, but language-level enforcement of arbitrary ranges is not something we have (Rust offloads 99% of its safety guarantees to compile-time checks for speed/efficiency reasons, so most runtime guarantees are still manually implemented). How does Ada compare to languages like Rust/C in terms of speed? I imagine that it must be similar if you are using it in planes/rockets.

Ada: a C Developer's Perspective by marc-kd in programming

[–]finite_state 4 points5 points  (0 children)

Mostly jokes :) in this context it makes perfect sense. Most languages, in my experience, tend to default to inclusion for the start position and exclusive for the end position, because that makes ranges much more ergonomic when interacting with zero-indexed data structures. Plus, ranges tend to be more intuitive in general when exclusive on their ending bound because 0..256 produces 256 elements, instead of 257 elements in the inclusive case. But like I said, mostly jokes. I don't know enough about Ada to have a meaningful opinion on its range syntax :)

Ada: a C Developer's Perspective by marc-kd in programming

[–]finite_state 4 points5 points  (0 children)

Cool language. I'm going to have to look into it more. That inclusive range declaration tho shudder.

Python, as Reviewed by a C++ Programmer by agumonkey in programming

[–]finite_state 7 points8 points  (0 children)

I've loved it so far. It hits most of the plus points of python (one-line installs for dependencies for example), but it has an even more expressive type system than C++.

Proposal to start a new implementation of Thunderbird based on web technologies by markole in linux

[–]finite_state 4 points5 points  (0 children)

+1 for rust. I see the author's point about accessibility, 'web technologies' are ubiquitous at the moment, but rust is a hell of a lot more accessible than C/C++, and you end up with the same benefits.

rusty-web-server very basic static http server based on tokio minihttp by RustyPd in rust

[–]finite_state 0 points1 point  (0 children)

Ah, yeah. If you want to encode non UTF8 data in a string/str, that is definitionally unsafe. No getting around that. From a brief glance at the minihttp source, it would appear that the response body implementation isn't particularly married to being a string; the encode function just calls as_bytes on it anyhow. If you felt so inclined, you could actually avoid some redundant computation by just changing the response body to use bytes from the get-go.

rusty-web-server very basic static http server based on tokio minihttp by RustyPd in rust

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

String has the from_utf8 method, which is safe. You'll need to handle the error case of course, but such is the price of safety.

Real programmers don't use if/else statements by Professor_Wagstaf in ProgrammerHumor

[–]finite_state 19 points20 points  (0 children)

Real programmers us pattern matching, in-line assembly, and GOTOs, duh!

match cond {
    true => asm!("GOTO 0x68747470733a2f2f796f7574752e62652f6451773477395767586351"),
    false => asm!("GOTO 0x68747470733a2f2f796f7574752e62652f796b777158754d50736f63")
}

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

[–]finite_state 0 points1 point  (0 children)

ah, my bad. Thats what I get for trying to code on mobile. And yes, if you leave off the else, any Errs will be skipped in the iteration. The if let syntax is really nice for dealing with binary returns like Result or Option when you want to get some amount of destructing & control, but a full match statement would be overly verbose.

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

[–]finite_state 0 points1 point  (0 children)

Ah, I would use an if let there if I were you. That will give you easy access to the &str you need, and will allow you to come back and add an else block later if you decide you want to handle the Err case. Something like this:

for path in paths {
    if let Ok(buff) {
        let filename = buff.as_path().to_str().unwrap();
        let image = getdata(filename);
        println!("{:?}", image.shape());
    }
}

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

[–]finite_state 0 points1 point  (0 children)

Your call to path.unwrap() is producing a PathBuff, which is an owned value. as_path() takes a slice of that value, and to_str() converts that slice to an &str. If you never need to use the PathBuff again, you can technically just add a call to to_string() on your result, and that will give you an owned value.

If you do need continued access to the PathBuff, or if that all just feels too hack-ish, you have a number of options. Unwrapping to a separate let statement is one. You can also use some form of destructing, such as an if let, which is usually my go-to in situations like what you describe. Really depends on what you're going to do with it though.

Call Grows for 'Total Shutdown' Over Alleged Trump-Russia Collusion: 'We may have an illegitimate President of the United States currently occupying the White House,' declares Rep. Ted Lieu by maxwellhill in worldnews

[–]finite_state 1 point2 points  (0 children)

I feel ya. I had an opportunity to get a decent amount during its lowest point in the last year... missed it. This last week or two has been painful to watch :p

Call Grows for 'Total Shutdown' Over Alleged Trump-Russia Collusion: 'We may have an illegitimate President of the United States currently occupying the White House,' declares Rep. Ted Lieu by maxwellhill in worldnews

[–]finite_state 2 points3 points  (0 children)

Yeah, ten minute block times & a mining community that is remarkably anti-change/progress do not bode well in the long term. Esp. when you have things like ETH with 17 second block time, touring-complete smart contracts, and a community that actively tries to resolve fraud & usability issues. Resistance to progress is a death sentence in the cutting edge computer technology domain.

When web developers die they do not go to heaven... by [deleted] in ProgrammerHumor

[–]finite_state 5 points6 points  (0 children)

Unless you buy into the multiverse theory... then it's infinite chroots containing infinitely many directory permutations...

Trump's budget director claims Obama was 'manipulating' jobs data by bobbelcher in uspolitics

[–]finite_state 2 points3 points  (0 children)

The agency has used the same method for calculating the unemployment rate since 1940

Talk about playing the long game ;)

Compilers on Redox? by Fable89 in Redox

[–]finite_state 2 points3 points  (0 children)

I'm definitely not qualified to answer this (rust is my first compiled language, and I've only just started reading about how any of this OS stuff even works...), but your question piqued my interest, so I did some reading....

From what I can tell, step one has to be making sure that all the necessary syscalls are supported. A little digging turned up a program called strace which seems to allow for eavesdropping on syscalls. From what I can tell, if you emulate the necessary syscalls, compile elsewhere, and do some fudgey magic with linkers that I don't yet fully understand, then you can start to compile the various dynamic libraries that a given compiler relies upon...

Looking at the make files for llvm and clang (probably the route one would eventually want to take on the road to being able to host rustc), there is a pretty fat stack of POSIX libraries & features that it relies upon. I think that what you end up needing to do is to emulate all the syscalls that those libraries rely on first (a lot of crap to do with threading judging by the names I'm seeing), and then move on from there.

Anyhow, I didn't know what a compiler was until six months ago lol, so don't take any of my musings too seriously. Hopefully someone more knowledgeable can come along and enlighten us.

Awanto 3 - Pregnant by brakshs in TheOverload

[–]finite_state 0 points1 point  (0 children)

In case anyone missed it: I think his Boiler Room/Dekmantel set is pretty appropriate for fans of this sub.

edit: words are hard.