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

Added static_face as variation of face #2520

Merged
merged 1 commit into from Sep 3, 2023
Merged

Added static_face as variation of face #2520

merged 1 commit into from Sep 3, 2023

Conversation

bleuthoot-sven
Copy link
Contributor

This copies the face() function in user.rs, but uses static_avatar_url instead of avatar_url.

I am not sure if the #[must_use] is needed, since I don't exactly know what it does. If not, I will remove it in a follow up commit.

@github-actions github-actions bot added the model Related to the `model` module. label Aug 26, 2023
@arqunis arqunis added the enhancement An improvement to Serenity. label Aug 26, 2023
@bleuthoot-sven
Copy link
Contributor Author

bleuthoot-sven commented Aug 26, 2023

Something of note, the model/guild/members.rs does not have a static_avatar_url function, so I did not add the static_face function to there.

@arqunis
Copy link
Member

arqunis commented Aug 26, 2023

I am not sure if the #[must_use] is needed, since I don't exactly know what it does. If not, I will remove it in a follow up commit.

#[must_use] is an attribute you can use on functions and structs. If on functions, it will prompt the compiler to issue a diagnostic if the caller of the function forgets to use the return value in any way, e. g.:

#[must_use]
fn rand() -> i32 {
    4
}

fn main() {
    rand(); // warning: unused return value of `rand` that must be used
}

On structs, the effect of the attribute will apply anywhere the type is used (that is, in any function where it is used as return type).

It is very useful if the whole point of calling a function is to perform further calculations on its return value, as the function does not have a side-effect (like writing to the filesystem); or if it does, there could be reasons why ignoring the return value might be bad (for instance, Results, because they might be Errs, or Iterators and Futures, which perform no work until next()/poll() is called).

@bleuthoot-sven
Copy link
Contributor Author

I am not sure if the #[must_use] is needed, since I don't exactly know what it does. If not, I will remove it in a follow up commit.

#[must_use] is an attribute you can use on functions and structs. If on functions, it will prompt the compiler to issue a diagnostic if the caller of the function forgets to use the return value in any way, e. g.:

#[must_use]
fn rand() -> i32 {
    4
}

fn main() {
    rand(); // warning: unused return value of `rand` that must be used
}

On structs, the effect of the attribute will apply anywhere the type is used (that is, in any function where it is used as return type).

It is very useful if the whole point of calling a function is to perform further calculations on its return value, as the function does not have a side-effect (like writing to the filesystem); or if it does, there could be reasons why ignoring the return value might be bad (for instance, Results, because they might be Errs, or Iterators and Futures, which perform no work until next()/poll() is called).

Ah, that's quite useful to know. Thanks for the information.

@arqunis arqunis merged commit 944e53c into serenity-rs:next Sep 3, 2023
21 checks passed
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 4, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 6, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Sep 21, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 17, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Oct 23, 2023
mkrasnitski pushed a commit to mkrasnitski/serenity that referenced this pull request Oct 24, 2023
arqunis pushed a commit to arqunis/serenity that referenced this pull request Oct 24, 2023
arqunis pushed a commit to arqunis/serenity that referenced this pull request Oct 24, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Oct 24, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Nov 1, 2023
mkrasnitski added a commit to mkrasnitski/serenity that referenced this pull request Nov 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An improvement to Serenity. model Related to the `model` module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants