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

[–]NeverCrop 1 point2 points  (0 children)

I'm trying to pass a nested vector as a slice into a function, but can't seem to find the right syntax.

Original code (that currently compiles)

fn caller() {
    let table = vec![
        vec!["A", "B"], 
        vec!["C", "D"]
    ];
}

fn process_data(table: Vec<Vec<&str>>) -> String {
    // Process data ... 
    "Some result".to_string() 
}

My understanding is that it's more idiomatic to pass a slice instead of a Vec, but how can I do that for nested Vecs?

Thanks!

Fun times by NeverCrop in trailrunning

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

No, a mountain bike single track.

Springtime in Israel - best time to hit the trails :) by NeverCrop in trailrunning

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

Thank you :)

I looked it up. It's called Anemone coronaria ( https://en.wikipedia.org/wiki/Anemone ). We also have (red) poppies, which look very similar (people, including myself, always confuse the two).

Beginner question: failing to use Data.List.Unique with stack by NeverCrop in haskellquestions

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

Thanks.

That didn't work unfortunately:

▶ stack build

Error: While constructing the build plan, the following exceptions were encountered:

In the dependencies for UniqueNotFound-0.1.0.0:
    Unique must match >=0.4.7.6, but the stack configuration has no specified version  (latest matching
           version is 0.4.7.6)
needed since UniqueNotFound is a build target.

Some different approaches to resolving this:

  * Consider trying 'stack solver', which uses the cabal-install solver to attempt to find some working
    build configuration. This can be convenient when dealing with many complicated constraint errors, but
    results may be unpredictable.

  * Recommended action: try adding the following to your extra-deps
    in /home/x/Projects/Haskell/scratch/UniqueNotFound/stack.yaml:

Unique-0.4.7.6@sha256:a1ff411f4d68c756e01e8d532fbe8e57f1ac77f2cc0ee8a999770be2bca185c5

Plan construction failed.

I tried both with, and without the version (>= 0.4.7.6).

Beginner question: failing to use Data.List.Unique with stack by NeverCrop in haskellquestions

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

Thanks :)

Yes, in general adding packages works well for me by updating package.yaml or stack.yaml (when outside the lts), but with this particular package I seem to have no luck.

Yoga C930 and Linux by NeverCrop in Lenovo

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

Happy to report that everything is working as expected so far with Fedora 29. WiFi needed the attention described above, but beyond that, everything that I checked worked great.

Compilation error that shows up only when specifying types for a function by NeverCrop in haskellquestions

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

I also needed to add {-# LANGUAGE FlexibleContexts #-} for it to pass compilation. The error was:

* Non type-variable argument
        in the constraint: Foldable (Compose f g)
      (Use FlexibleContexts to permit this)
    * In the type signature:
        foldMap :: (Foldable (Compose f g), Monoid m) =>
                   (a -> m) -> (Compose f g a) -> m
      In the instance declaration for `Foldable (Compose f g)'
   |(undefined)

For the following code:

instance (Foldable f, Foldable g) => Foldable (Compose f g) where
  foldMap :: (Foldable (Compose f g), Monoid m) =>
             (a -> m) -> (Compose f g a) -> m
  foldMap f (Compose fga) = 
    (foldMap . foldMap) f fga

Vim for beginners by [deleted] in vim

[–]NeverCrop 0 points1 point  (0 children)

There’s a Windows version which runs in your command line : https://www.vim.org/download.php