Skip to content

Feature/generics3 updt from old pr #2043

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

poneciak57
Copy link
Contributor

Created a new pull request based on the previous one (#1470).

Added a new generic exercise that focuses on function reusability using generics.

@poneciak57
Copy link
Contributor Author

poneciak57 commented Jul 11, 2024

One of the checks failed Rustlings Tests / dev-check (pull_request)
It told me to run command cargo run -- dev update but this failed should i open an issue or should i just update this file manually ?

windows 11
rustup 1.27.1
cargo 1.79.0
Error message:

cargo run -- dev update
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.18s
     Running `target\debug\rustlings.exe dev update`
Error: Failed to update the file `dev/Cargo.toml`

Caused by:
    Failed to find the start of the `bin` list (`bin = [`)
error: process didn't exit successfully: `target\debug\rustlings.exe dev update` (exit code: 1)

@mo8it
Copy link
Contributor

mo8it commented Jul 12, 2024

I can take care of the CI test later. Probably a Windows issue.

We shouldn't use traits / trait bounds because the exercises about them are after the generics exercises.

How about a function taking &[Option<T>] and returning Vec<T> containing only the Some values?

@poneciak57
Copy link
Contributor Author

I changed stringify to this:

fn into_dispose_nulls<T>(list: Vec<Option<T>>) -> Vec<T> {
    list.into_iter().flatten().collect()
}

i tried to have &[Option<T>] as an argument but it requires T to implement Clone (and i couldn't find any suitable workaround)

@mo8it
Copy link
Contributor

mo8it commented Jul 12, 2024

i tried to have &[Option] as an argument but it requires T to implement Clone (and i couldn't find any suitable workaround)

Oh, yeah. We would need to return something like Vec<&T> otherwise. But this is fine how you did it with Vec as argument.

@mo8it mo8it added this to the v7 milestone Jul 12, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants