r_rust🦀


Channel's geo and language: not specified, not specified
Category: not specified


Posts top submissions from the rust subreddit every hour.
Powered by: @reddit2telegram
Chat: @r_channels

Related channels

Channel's geo and language
not specified, not specified
Statistics
Posts filter


Error trying to build deepspeech-rs, bindings for deepspeech

This command: cargo run --verbose --release --example client /home/pi/Downloads/ /home/pi/Downloads/audio/2830-3980-0043.wav

This uses the Cargo.toml that is part of the download for deepspeech-rs. This builds two libraries for deepspeech. Any thoughts on this?

error\[E0465\]: multiple rlib candidates for \`deepspeech\` found

\--> examples/client.rs:1:1

|

1 | extern crate deepspeech;

| \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

|

note: candidate #1: /home/pi/deepspeech-rs/target/release/deps/libdeepspeech-8c31f94611999af5.rlib

\--> examples/client.rs:1:1

|

1 | extern crate deepspeech;

| \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^

note: candidate #2: /home/pi/deepspeech-rs/target/release/deps/libdeepspeech-f5785e43f263827b.rlib

\--> examples/client.rs:1:1

|

1 | extern crate deepspeech;

| \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^



error\[E0463\]: can't find crate for \`deepspeech\`

\--> examples/client.rs:1:1

|

1 | extern crate deepspeech;

| \^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^\^ can't find crate



error: aborting due to 2 previous errors



For more information about this error, try \`rustc --explain E0463\`.

error: could not compile \`deepspeech\`.

https://redd.it/hido3s
@r_rust


New to programming languages. Is a RUST a good place to start?

Hi All,

I am completely new to programming languages/development and stumbled upon Stack Overflow's "Developer's Survey 2019", in which, the community gave their opinions on languages. According to the survey, Rust was the most Loved technology, edging out Python and TypeScript, so I figured I'd start here.

My recent interest in programming is really brought on by my lack of satisfaction in my current industry (Healthcare), and lack of interest/mental challenge of my position (supply chain/procurement). I've taken a few of those "strengths finders" and personalities tests, and I'm always heavily labeled a Logician. I figured programming might be a good fit so, help me: is RUST a good language to start with? I found "The Book" and plan to give it a read but I'd like opinions as well.

Thanks,

Ciabattabingo

https://redd.it/hi9gib
@r_rust


crossfire: yet another async mpmc/mpsc based on crossbeam-channel

When last year I began to work on our storage project, there were no mpmc to support async code, and we need something fast enough to serve as backbone I/O pipeline. So I decided to build this base on crossbeam. Lately I feel it's finally stable enough to open source, and it has been heavily tested along with our storage project. I took the name "crossfire" as a derive from crossbeam.

A few days ago @[stjepang](https://www.reddit.com/user/stjepang/) publish async-channel, it has simular goal. But crossfire took some different aproach, since waker is wrapped from std waker and require less denpendency. Additionally crossfire support comunication between async code and threaded code. (This feature is not seen elsewhere).

You are welcome to give it a try.

[https://docs.rs/crossfire/](https://docs.rs/crossfire/)

https://redd.it/hi9vhj
@r_rust


Platform keyboard event handling

We just landed [druid#1049](https://github.com/linebender/druid/pull/1049), which significantly reworks and improves keyboard event handling in Druid. In particular, I think it has a really good implementation of platform keyboard handling on Windows, and good enough on macOS, Gtk, and Web. Windows keyboard handling is especially tricky to get right, and in researching this I found a range of implementation quality from hopelessly broken to basically right but quite complex (particularly the browser implementations).

Another nice feature of this patch is that we're moving more towards standard types - it's using the [keyboard-types](https://crates.io/crates/keyboard-types) crate (though doing a few of our own newtypes, and having conversations with upstream about converging even more).

I should also point out that the larger task of keyboard handling is still work in progress. There are some things to fix about hotkeys (especially with non-Latin keyboard layouts), and we don't yet do IME.

The reason I am posting here, rather than just on our Zulip, is that I'd like to open some discussion about how to improve things across the ecosystem, not just in Druid. The simplest thing is for people responsible for other UI platform bindings to be aware of our implementation, study it, and adapt it.

Are there other ways the ecosystem can work together? Should we be investing in "vocabulary types" like keyboard-types? What are the best ways to do this without running into difficult coordination problems?

Discussion welcome.

https://redd.it/hi9aq2
@r_rust






Question about Python FFI and the GIL

tl;dr I would love to be able to call a Python function from Rust in multiple concurrent threads. My understanding is that the GIL makes this impossible. Is that correct?

Use case: I'm trying to implement a tree search where nodes of the tree are sometimes scored by a user-defined evaluation function. In Rust, it should be easy to multithread this so that several nodes can be explored in parallel (for the class of evaluation functions that the compiler can prove are safe to call in parallel, at least). I'd like to expose the search API as a Python module, but that would imply the evaluation function would now be written in Python too. At that point, it seems impossible to get the benefits of parallelism, since the GIL would need to be acquired by the acting thread every time the evaluation function is called.

Am I understanding this right, or is there some sneaky way to get a parallel speedup for functions that call Python code (even if only a restricted class of Python functions)?

https://redd.it/hi6snp
@r_rust


Exploring ways of accessing cells of a 2D matrix backed by a regular Vec/array

I'm using an array/vector to back a 2-dimensional matrix. Now to get a "cell" we of course would use the `num_cols * y + x` formula, however I found 3 ways of obtaining an element:

This one can of course panic, but also, I think there's a possibility of integer overflow:

pub fn get_item2(items: &[u8], width: usize, x: usize, y: usize) -> Option {
Some(items[width * y + x])
}

This one won't panic because of an out of bounds index, but I think the integer overflow is still possible:

pub fn get_item3(items: &[u8], width: usize, x: usize, y: usize) -> Option {
items.get(width * y + x).cloned()
}

Now I came up with this version (which I ended up using) that I like because there's no possibility of out-of-bound panics and I think I eliminated the posibility of integer overflow, since I'm not multiplying anything...

pub fn get_item(items: &[u8], width: usize, x: usize, y: usize) -> Option {
items.chunks(width).nth(y).and_then(|chunk| chunk.get(x)).cloned()
}

Am I correct? Is the last version "safer"? Are there other ways of doing this?

https://redd.it/hi5ozp
@r_rust


What's the best way to evaluate a string containing a mathematical expression while following order of operations?

Say for example you have `let expr: &str = "14 + 10 / 2 - 3 * 5` which should evaluate to `4`.

What's the best way of doing this via rust? My first inclination is to split the string by the lower-precedence operations (`+` & `-`), evaluate the substrings (which will then contain either `*` or `/`) and then sum/subtract up those results. The only way I can think of doing this is via higher-order functions like `fold()`. Does anyone else have alternative suggestions?

https://redd.it/hi14zo
@r_rust




Announcing const-sha1: a sha1 implementation for use in const contexts 🎉
https://crates.io/crates/const-sha1

https://redd.it/hi11op
@r_rust






Rust structs - Wasm Loading dynamically

Hey People,


I got a small Problem with WebAssembly and its imports. I want to load the wasm file dynamically to my javascript file. It looks something like this:


//javascriptfile.js

const rust = import('./../eye-move-image/pkg/eye_move_image_bg.wasm')
let code;

function setup(m){
code = m;
console.log(code.greet());
let instance = code.Foo.new();
console.log(code.bar());
}

rust
.then(m => setup(m))
.catch(console.error)


And here the Rust file:


//rustfile.rs
use wasm_bindgen::prelude::*;

#[wasm_bindgen]
pub fn greet() -> i32{
42
}


#[wasm_bindgen]
pub struct Foo{
val : i32,
}

#[wasm_bindgen]
impl Foo{
pub fn new() -> Foo{
Foo {
val: 3,
}
}

pub fn bar(&self) -> i32{
self.val
}
}


I am compiling the rust code with the following Command without flags.

wasm-pack build

By the wasm\_bindgen Guide( [https://rustwasm.github.io/docs/wasm-bindgen/examples/char.html](https://rustwasm.github.io/docs/wasm-bindgen/examples/char.html) )
this should work, shouldn't it? I am kinda frustrated right now.


The console.log(greet()) call works. But The call of the new() methode doesnt, do you have to call the methods in a different way, or what is the problem?

https://redd.it/hhzmao
@r_rust






How to specify a location to put another binary file in ./target/.... ?

I have another executable binary file. Let's call it `e.exe`. How can I specify in cargo.toml or somewhere else to tell `cargo` to put this `e.exe` in a specific location once I type `cargo build`?

Emm, for example, the resulting directory may be like this:

```
target:
debug:
my_prog_produced_by_cargo.exe
a_folder_I_appointed_to_cargo_to_store_the_dependency:
e.exe
```

> Sorry for the unclearness but I am new to programming and really have little idea on how to make a project, or any terminologies related to this topic...
>
> Many thanks ahead!

Edit:

When I used other programs, I often find that there are A LOT OF things in the directory. But later when I started to learn coding, I found that I could only produce a *single* program, not anything like the programs we use every day.

Of course I can manually put other files in. But I then learned that this thing called project manager or IDE exists to help me manage the dependencies or non-code files. However, I still have no idea on how to produce a program *with* many other files it can use...

https://redd.it/hhvxsq
@r_rust




What's everyone working on this week (27/2020)?

New week, new Rust! What are you folks up to? Answer here or over at [rust-users](https://users.rust-lang.org/t/whats-everyone-working-on-this-week-27-2020/45101?u=llogiq)!

https://redd.it/hhv5ks
@r_rust


Hey Rustaceans! Got an easy question? Ask here (27/2020)!

Mystified about strings? Borrow checker have you in a headlock? Seek help here! There are no stupid questions, only docs that haven't been written yet.

If you have a [StackOverflow](http://stackoverflow.com/) account, consider asking it there instead! StackOverflow shows up much higher in search results, so having your question there also helps future Rust users (be sure to give it [the "Rust" tag](http://stackoverflow.com/questions/tagged/rust) for maximum visibility). Note that this site is very interested in question quality. I've been asked to read a RFC I authored once. If you want your code reviewed or review other's code, there's a [codereview stackexchange](https://codereview.stackexchange.com/questions/tagged/rust), too. If you need to test your code, maybe [the Rust playground](https://play.rust-lang.org) is for you.

Here are some other venues where help may be found:

[/r/learnrust](https://www.reddit.com/r/learnrust) is a subreddit to share your questions and epiphanies learning Rust programming.

The official Rust user forums: [https://users.rust-lang.org/](https://users.rust-lang.org/).

The official Rust Programming Language Discord: [https://discord.gg/rust-lang](https://discord.gg/rust-lang)

The unofficial Rust community Discord: [https://bit.ly/rust-community](https://bit.ly/rust-community)

Also check out [last week's thread](https://reddit.com/r/rust/comments/hdku4k/hey_rustaceans_got_an_easy_question_ask_here/) with many good questions and answers. And if you believe your question to be either very complex or worthy of larger dissemination, feel free to create a text post.

Also if you want to be mentored by experienced Rustaceans, tell us the area of expertise that you seek.

https://redd.it/hhv4z1
@r_rust

20 last posts shown.

11

subscribers
Channel statistics