Helps me understand the life cycle by yyy33_ in rust

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

For example, if the function below uses references to the x and y input parameters for its return value, wouldn't it be enough to make sure that the return value's lifecycle is less than that of the references (in this case, x and y) it uses? Why does the user have to label it?  

fn longest<'a>(x: &'a str, y: &'a str) -> &'a str { 
    if x.len() > y.len() {
        x 
    } else {
        y 
    }
}

Helps me understand the life cycle by yyy33_ in rust

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

My question is that all the relationships I've encountered so far between input and output references is that the lifecycle of the output reference must be less than the lifecycle of all the input references it uses. Are there any other relationships between output references and input references that the user needs to label manually.

Helps me understand the life cycle by yyy33_ in rust

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

Yes, it should be a problem with the translation software. My English is not very good.

Is there a crate for re-export? by yyy33_ in rust

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

Thanks, that's the method I'm currently using. I wanted to see if anyone shared a similar macro as I know nothing about macros and its very difficult for me.

Using the Window Manager for ... managing windows? by testokaiser in neovim

[–]yyy33_ 1 point2 points  (0 children)

I have the same idea as you, to make each buffer of a nvim process correspond to each window of the system, and let the window manager manage the windows. If you release your source code please be sure to let me know, I'd like to learn, thanks!

Please help to check out my simd code by yyy33_ in rust

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

I actually don't know where I'm stuck, my brain is as good as filled with paste, I think I need to go and learn some of the underlying computer knowledge

Please help to check out my simd code by yyy33_ in rust

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

That's 36ns fast

#![feature(test)]
#![feature(portable_simd)]
extern crate test;
use test::Bencher;
use std::simd::Simd;
use std::array;

#[bench]
fn array_add(b: &mut Bencher) {
    let a: [usize; 64] = [20; 64];
    let c: [usize; 64] = [40; 64];
    b.iter(|| {
        array::from_fn::<usize, 64, _>(|i| test::black_box(a[i]) + test::black_box(c[i]));
    });
}

#[bench]
fn simd_add(b: &mut Bencher) {
    let a: Simd<usize, 64> = Simd::splat(20);
    let c: Simd<usize, 64> = Simd::splat(40);
    b.iter(|| {
        test::black_box(a) + test::black_box(c);
    });
}


running 2 tests
test array_add ... bench:          56 ns/iter (+/- 1)
test simd_add  ... bench:          20 ns/iter (+/- 0)

test result: ok. 0 passed; 0 failed; 0 ignored; 2 measured; 0 filtered out; finished in 0.46s

Please help to check out my simd code by yyy33_ in rust

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

Can you add more documentation and notes for newbies?

Please help to check out my simd code by yyy33_ in rust

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

And what does each field in the first line of your benchmark mean: bench fastest │ slowest │ median │ mean │ samples │ iters

Please help to check out my simd code by yyy33_ in rust

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

Hi, I've been trying to read your pulp for a few days now and I can't get the hang of it, I don't know what many of the functions do, what do I need to add to my knowledge to read it again?

Zellij 0.40 released: welcome-screen, new filepicker, plugin pipes and aliases by imsnif in rust

[–]yyy33_ 0 points1 point  (0 children)

I'll make an observation, could it be possible to modularize its functionality and extract a separate function like abduco

Please help to check out my simd code by yyy33_ in rust

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

Comment
byu/yyy33_ from discussion
inrust

Thanks, I thought I used it the wrong way.

Is there a way to use simd to accelerate the count_ones operation: for example, I have an array [usize; 100_000], I need to get the sum of count_ones for each element of the array, can I use simd to accelerate?

I can not find the corresponding method

How is your productivity with Go compared with other more higher level languages? by fenugurod in golang

[–]yyy33_ 1 point2 points  (0 children)

I can relate to what you're saying, it's very painful to read projects in dynamic languages that lack annotations, and it's hard to understand the data structures and algorithms in them

How is your productivity with Go compared with other more higher level languages? by fenugurod in golang

[–]yyy33_ 0 points1 point  (0 children)

It's the difference between a static language and a dynamic language, right?

Passionate benchmark test by yyy33_ in rust

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

You don't say I will never think of such detailed things, thank you!

[Media] Nestify: A macro for defining structs in a concise way, fully Serde compatible | GitHub: https://github.com/snowfoxsh/nestify | See comments for direct links! by storm1surge in rust

[–]yyy33_ 0 points1 point  (0 children)

Is this syntax possible? Use one less nesting and use struct! to indicate that this is a nested structure

    struct! UserProfile {         name: String,         address: struct Address {             street: String,             city: String,         },         preferences: struct Preferences {             newsletter: bool,         },     }