Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

optimized the UI code #1830

Merged
merged 4 commits into from Mar 15, 2024
Merged

optimized the UI code #1830

merged 4 commits into from Mar 15, 2024

Conversation

AnonimAnonim2245
Copy link
Contributor

@AnonimAnonim2245 AnonimAnonim2245 commented Jan 18, 2024

I did a refactoring on the 'warn' and 'succes' macros. And created a new macro called print_emojis which did what the previous macros did but more generalized. I used the expr for "$emoji" and "$sign", because it can accept any UTF8 characters. In the case of "$color", I used the ident because it allowed me for customizability for the colour, because the variable to be used as an identifier(in my case a function)
I did this in order to avoid the duplication from the original code

@alexandruradovici
Copy link

Please describe your pull request.

@AnonimAnonim2245
Copy link
Contributor Author

I did a refactoring on the 'warn' and 'succes' macros. And created a new macro called print_emojis which did what the previous macros did but more generalized. I used the expr for "$emoji" and "$sign", because it can accept any UTF8 characters. In the case of "$color", I used the ident because it allowed me for customizability for the colour, because the variable to be used as an identifier(in my case a function)

@AnonimAnonim2245
Copy link
Contributor Author

I did this in order to avoid the duplication from the original code

@alexandruradovici
Copy link

I did a refactoring on the 'warn' and 'succes' macros. And created a new macro called print_emojis which did what the previous macros did but more generalized. I used the expr for "$emoji" and "$sign", because it can accept any UTF8 characters. In the case of "$color", I used the ident because it allowed me for customizability for the colour, because the variable to be used as an identifier(in my case a function)

Please add it to the beginning of the pull request.

@shadows-withal shadows-withal merged commit 17ee0e3 into rust-lang:main Mar 15, 2024
5 checks passed
@shadows-withal
Copy link
Member

@all-contributors please add @AnonimAnonim2245 for code

Copy link
Contributor

@shadows-withal

I've put up a pull request to add @AnonimAnonim2245! 🎉

maladroitthief pushed a commit to maladroitthief/rustlings that referenced this pull request Mar 27, 2024
jhrcook pushed a commit to jhrcook/rustlings that referenced this pull request Apr 13, 2024
jhrcook added a commit to jhrcook/rustlings that referenced this pull request Apr 13, 2024
* solutions: intro, variables, functions, if, quiz1

* solutions: primitive types, move semantics, vecs, structs, enums

* solutions: strings, hashmaps, modules, quiz 2

* solutions: options and error_handling

* solutions: generics, traits, and quiz 3

* solutions: lifetimes, tests

* solutions: iterators

* feat: smart pointers

* solutions: macros

* solutions: threads

* solutions: clippy

* solutions: conversions

* chore: make hints proper markdown

Also rewrapped some hints to 80 columns so that they also look good in a
terminal.

closes rust-lang#1698

* docs: use new fancy install aliases

* chore(errors1): fix grammar typo in hint for exercise errors1

This commit corrects a grammar typo in the hint of the errors1 exercise, changing from:
"`Ok` and `Err` are one of the variants of `Result`,"
to:
"`Ok` and `Err` are the two variants of `Result`,"

* chore(errors2): minor description wording change

This commit makes a minor change in the wording of the description of the errors2 exercise to avoid potential confusion, changing:

"A player of the game will type in how many items they want to buy, and the `total_cost` function will calculate the total cost of the tokens."
to
"A player of the game will type in how many items they want to buy, and the `total_cost` function will calculate the total cost of the items."

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Update Exercises Directory Names to Reflect Order

* Update install.sh

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(watch): update the CLIPPY_CARGO_TOML_PATH

... to reflect the changes to the exercise directory names.

The path exercises/clippy replaced with exercises/22_clippy.

closes rust-lang#1726

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: fix windows installation instructions

Currently, the windows installation instructions download a script from the URL ps1.rustlings.cool. This URL isn't detected as a URL in some cases, which means that PowerShell tries to load the data from a local file called ps1.rustlings.cool.

This was breaking my install, and adding the https:// fixed it.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(intro1.rs): typo in the exercise body

* fix(intro2): changed intro2 to be a name error, not a format string error.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix progress bar count

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(traits3): grammar mistake in the hint for traits3

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Add CodeCrafters

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: revert fancy install aliases

* Revert "Add CodeCrafters"

This reverts commit dad2216.

* Revert "docs: add sarupbanskota as a contributor for doc"

* chore(watch): update notify dependency to v6

closes rust-lang#1640

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(watch): Fix rendering of the finishing ferris

In commit 571bab2 ("Run clippy --fix"), the "" string was changed to
r"", even though it contains an intentional escape sequence, which now
looks wrong. My commit undoes this change:

Before:

	+----------------------------------------------------+
	|          You made it to the Fe-nish line!          |
	+--------------------------  ------------------------+
				  \\/
	     ▒▒          ▒▒▒▒▒▒▒▒      ▒▒▒▒▒▒▒▒          ▒▒
	   ▒▒▒▒  ▒▒    ▒▒        ▒▒  ▒▒        ▒▒    ▒▒  ▒▒▒▒
	   ▒▒▒▒  ▒▒  ▒▒            ▒▒            ▒▒  ▒▒  ▒▒▒▒
	 ░░▒▒▒▒░░▒▒  ▒▒            ▒▒            ▒▒  ▒▒░░▒▒▒▒
	   ▓▓▓▓▓▓▓▓  ▓▓      ▓▓██  ▓▓  ▓▓██      ▓▓  ▓▓▓▓▓▓▓▓
	     ▒▒▒▒    ▒▒      ████  ▒▒  ████      ▒▒░░  ▒▒▒▒
	       ▒▒  ▒▒▒▒▒▒        ▒▒▒▒▒▒        ▒▒▒▒▒▒  ▒▒
		 ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
		   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
		     ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
		   ▒▒  ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒  ▒▒
		 ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒
	       ▒▒    ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒    ▒▒
	       ▒▒  ▒▒    ▒▒                  ▒▒    ▒▒  ▒▒
		   ▒▒  ▒▒                      ▒▒  ▒▒


After:

	+----------------------------------------------------+
	|          You made it to the Fe-nish line!          |
	+--------------------------  ------------------------+
				   \/
	     ▒▒          ▒▒▒▒▒▒▒▒      ▒▒▒▒▒▒▒▒          ▒▒
	   ▒▒▒▒  ▒▒    ▒▒        ▒▒  ▒▒        ▒▒    ▒▒  ▒▒▒▒
	   ▒▒▒▒  ▒▒  ▒▒            ▒▒            ▒▒  ▒▒  ▒▒▒▒
	 ░░▒▒▒▒░░▒▒  ▒▒            ▒▒            ▒▒  ▒▒░░▒▒▒▒
	   ▓▓▓▓▓▓▓▓  ▓▓      ▓▓██  ▓▓  ▓▓██      ▓▓  ▓▓▓▓▓▓▓▓
	     ▒▒▒▒    ▒▒      ████  ▒▒  ████      ▒▒░░  ▒▒▒▒
	       ▒▒  ▒▒▒▒▒▒        ▒▒▒▒▒▒        ▒▒▒▒▒▒  ▒▒
		 ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
		   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
		     ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
		   ▒▒  ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒  ▒▒
		 ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒
	       ▒▒    ▒▒    ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒    ▒▒    ▒▒
	       ▒▒  ▒▒    ▒▒                  ▒▒    ▒▒  ▒▒
		   ▒▒  ▒▒                      ▒▒  ▒▒

Running `cargo clippy` (version 0.1.70) after this commit does not
reveal any new warnings.

Fixes: 571bab2 ("Run clippy --fix")

* feat(watch): Add red color to the finishing ferris

This adds some eye-candy for users who finish Rustlings. It is based on
ANSI terminal escape sequences and should work in most environments.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Reword clippy1 exercise to be more readable

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Correct for more standard English

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore: fixed minor typo

* fix: revert from_into test change

* optimized the UI code (rust-lang#1830)

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore: update from_into.rs task description to fit the code

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix: Ensure scripts have LF line endings

Use gitattributes file to ensure script files have LF line endings. This solves a problem for users who wish to use DevContainers on Windows machines and the file has been cloned from the repository with CRLF line endings.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Clarified hint text

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore(deps): bump mio from 0.8.9 to 0.8.11

Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.9 to 0.8.11.
- [Release notes](https://github.com/tokio-rs/mio/releases)
- [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md)
- [Commits](tokio-rs/mio@v0.8.9...v0.8.11)

---
updated-dependencies:
- dependency-name: mio
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>

* Convert to lightweight dev container; simplify.

Instead of running `rustup` on a multi-gigabyte general-purpose Linux base, use the premade devcontainers/rust:1 which closely tracks the rust toolchain releases. Rip out excess setup steps since devcontainers come with the repo checked out; just compile/update the binary.

* Add target directory to $PATH

Makes the pre-built command work in the shell right away.

* Remove duplicate vscode extension list.

It's already in the vendor-specific .vscode files.

* Add back the post-attach watch.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore: fix typo

Signed-off-by: pavedroad <qcqs@outlook.com>

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore: minor typo fix

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Update hashmaps3.rs description for clarity

I struggled with this exercise and didn't understand that it was looking for a summary of goals scored/conceded per team, instead of per match.

My goal here is just to clarify the language, essentially saying "the total number of goals the team scored" to indicate that we are looking for a sum.

Updated the exercise description to clarify this point.

Relates loosely to closed issue rust-lang#1361

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Added .git to end of Repo's https URL

The install.sh script didn't work for me, after I changed this locally it worked
URL needs to end in .git

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(move_semantics): removed unused mut

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Update dependencies

* fix: clean up "return" wording in iterators4

* docs: Added comment for handling equal numbers in if/if1.rs `bigger` function

* Update exercises/03_if/if1.rs

Co-authored-by: liv <shadows@with.al>

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* fix(verify): show stdout of the last line

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Fix the sysroot path when it contains whitespaces

* Remove unneeded Arc

* options1: Update wording & fix grammar

Signed-off-by: Dan Bond <danbond@protonmail.com>

* verify: fix success message spacing

Signed-off-by: Dan Bond <danbond@protonmail.com>

* Use a custom capacity for the JSON buffer

* Add anyhow

* Merge get_sysroot_src into the constructor

* Avoid allocations on every call to Path::join

* Don't capture stderr

* Use the parsed exercises instead of glob

* Remove unneeded check if crates is empty

* RustAnalyzerProject is not deserialized

* Optimize the serialized data types

* Add write_project_json

* Add comment

* Cache filters

* Remove unneeded to_string call

* Optimize state

* Use to_string_lossy

* Call looks_done only once

* Replace regex with winnow

* Make "I AM NOT DONE" caseless

* Fix context of previous lines and improve readability

* Add comments

* Improvements to watch mode

* Initialize the input buffer with some capacity

* Move the const string to the bottom like others

* Replace toml with toml_edit

* Use the NotFound variant of the IO error

* Use `which` instead of running `rustc --version`

* Derive Eq when PartialEq is derived

* Only use arg instead of args AND arg

* Formatting

* Add missing semicolon

* Use == on simple enums

* Use == instead of eq

* Remove unneeded closure

* The string doesn't have to be a raw string

* Remove the home dependency since it is not used

* Pipe the output to null instead of capturing and ignoring it

* feat: ui format

* Update deps

* docs: sort exercise to book chapter mapping by exercise

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* chore: update the chapter of macros

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Remove confusing aside in 23_conversions/from_str.rs

The advice tell us how to return as String error message. Unless I missed something, we can't even return a String error message here, so this advice is more confusing than anything and should better be removed.

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* Remove outdated info about the command line parser

* Update the link to conventionalcommits.org

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* threads2: simplify threads2

* Remove the reference to v1

* Fix gitignore for clippy exercise

* docs: add more info in threads

info.toml: 

```toml
[[exercises]]
name = "threads3"
path = "exercises/threads/threads3.rs"
mode = "test"
hint = """
An alternate way to handle concurrency between threads is to use
a mpsc (multiple producer, single consumer) channel to communicate.
With both a sending end and a receiving end, it's possible to
send values in one thread and receive them in another.
Multiple producers are possible by using clone() to create a duplicate
of the original sending end.
See https://doc.rust-lang.org/book/ch16-02-message-passing.html for more info.
"""
```

threads3'hint contains this link, so it should be placed in Further Information

* docs: update AUTHORS.md [skip ci]

* docs: update .all-contributorsrc [skip ci]

* solutions: intro, variables, functions, if, quiz1

* solutions: macros

* solutions: finish threads2 after syncing main

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: pavedroad <qcqs@outlook.com>
Signed-off-by: Dan Bond <danbond@protonmail.com>
Co-authored-by: Joshua Cook <jhrcook@Joshuas-MacBook-Pro.local>
Co-authored-by: Rogier 'DocWilco' Mulhuijzen <github@bsdchicks.com>
Co-authored-by: liv <mokou@fastmail.com>
Co-authored-by: Matt Nield <64328730+matthewjnield@users.noreply.github.com>
Co-authored-by: allcontributors[bot] <46447321+allcontributors[bot]@users.noreply.github.com>
Co-authored-by: Adam Brewer <adamhb321@gmail.com>
Co-authored-by: The Bearodactyl <114454115+TheBearodactyl@users.noreply.github.com>
Co-authored-by: markgreene74 <markgreene74@users.noreply.github.com>
Co-authored-by: Versha Dhankar <45564258+VeeDeltaVee@users.noreply.github.com>
Co-authored-by: Tristram Oaten <tris@oat.sh>
Co-authored-by: danieltinazzi <Macbook@FengmingdeMacBook-Air.local>
Co-authored-by: Raymon Roos <raymon.roos@hotmail.com>
Co-authored-by: Sarup Banskota <sbanskota08@gmail.com>
Co-authored-by: liv <shadows_withal@fastmail.com>
Co-authored-by: Adwait Kumar Singh <adwsingh@amazon.com>
Co-authored-by: Dilshad <98999149+a-rustacean@users.noreply.github.com>
Co-authored-by: Matthias Richter <matthias.ri97@gmail.com>
Co-authored-by: J. Neuschäfer <j.neuschaefer@gmx.net>
Co-authored-by: Bastian Pedersen <bastian.tangedal@gmail.com>
Co-authored-by: Sergei Gerasenko <sgerasenko@conversantmedia.com>
Co-authored-by: LeverImmy <506503360@qq.com>
Co-authored-by: liv <shadows_withal@pm.me>
Co-authored-by: Luca Plian <98339220+AnonimAnonim2245@users.noreply.github.com>
Co-authored-by: reifenrath-dev <rene@reifenrath.dev>
Co-authored-by: Peter Neave <peter.neave@purple.telstra.com>
Co-authored-by: Jan <janbumer1@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Kyle VanderBeek <kylev@kylev.com>
Co-authored-by: pavedroad <qcqs@outlook.com>
Co-authored-by: luna <26529488+hyphena@users.noreply.github.com>
Co-authored-by: Evan Miller <evanmiller2112@gmail.com>
Co-authored-by: luvchurchill <46406654+luvchurchill@users.noreply.github.com>
Co-authored-by: parnavh <parnav100sach@gmail.com>
Co-authored-by: mo8it <mo8it@proton.me>
Co-authored-by: Guizoul <guizoul.abdellah@ine.inpt.ma>
Co-authored-by: guizo792 <95940388+guizo792@users.noreply.github.com>
Co-authored-by: liv <shadows@with.al>
Co-authored-by: Kazuki Matsuo <kazuki.matsuo.728@gmail.com>
Co-authored-by: Dan Bond <danbond@protonmail.com>
Co-authored-by: honeywest <honeywest@foxmail.com>
Co-authored-by: Paul Leydier <paul.leydier@compass-ft.com>
Co-authored-by: wznmickey <first@wznmickey.com>
Co-authored-by: NicolasRoelandt <NicolasRoelandt@users.noreply.github.com>
Co-authored-by: junderw <jonathan.underwood4649@gmail.com>
Co-authored-by: YunShu <im@yunshu.site>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants