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

doc(base): update lying doc comment of compute_display_name #4465

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Jan 6, 2025

It claimed that it would immediately return when the cached display name value was computed, but that's absolutely not the case.

Spotted while reviewing a PR updating iamb to the latest version of the SDK.

@bnjbvr bnjbvr requested a review from a team as a code owner January 6, 2025 17:37
@bnjbvr bnjbvr requested review from stefanceriu and removed request for a team January 6, 2025 17:37
Copy link

codecov bot commented Jan 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.04%. Comparing base (1480fad) to head (248f5e7).
Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4465      +/-   ##
==========================================
- Coverage   85.06%   85.04%   -0.02%     
==========================================
  Files         283      283              
  Lines       31748    31766      +18     
==========================================
+ Hits        27005    27016      +11     
- Misses       4743     4750       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@stefanceriu stefanceriu requested review from a team and jmartinesp and removed request for stefanceriu and a team January 6, 2025 20:14
Copy link
Contributor

@poljar poljar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A bit tangentially related, but why don't we have a method that does what the docs claim to do?

A method like this:

pub async fn foo() -> StoreResult<RoomDisplayName> {
    if let Some(result) = self.cached_display_name() {
        result
    } else {
        self.compute_dislpay_name().await
    }
}

We may even call this method just display_name() and people wouldn't need to think about the other two methods, unless they really care about never hitting the slow path.

crates/matrix-sdk-base/src/rooms/normal.rs Outdated Show resolved Hide resolved
@bnjbvr
Copy link
Member Author

bnjbvr commented Jan 7, 2025

A bit tangentially related, but why don't we have a method that does what the docs claim to do?

Ah nice, I thought that the reason was that compute_display_name was defined in the base crate, and used in the main crate, but that's not true! So we could have compute_display_name be private in the base crate, and expose a public method like that you propose. Will do as a followup!

It claimed that it would immediately return when the cached display name
value was computed, but that's absolutely not the case.

Spotted while reviewing a PR updating `iamb` to the latest version of
the SDK.
@bnjbvr bnjbvr force-pushed the bnjbvr/update-doc-comment-for-compute-display-name branch from 1649bbd to 248f5e7 Compare January 7, 2025 13:22
@bnjbvr bnjbvr enabled auto-merge (rebase) January 7, 2025 13:22
@bnjbvr bnjbvr merged commit 5110aa6 into main Jan 7, 2025
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/update-doc-comment-for-compute-display-name branch January 7, 2025 13:39
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.

2 participants