Skip to content

Commit 1a84cd6

Browse files
committed
Auto merge of #18011 - Wilfred:op_queue_doc_comments, r=Veykril
internal: Add doc comments to OpQueue I spent a while debugging some OpQueue behaviours and found the API slightly confusing, so I've added doc comments to clarify what each OpQueue method does.
2 parents 30c14ca + 730e7fb commit 1a84cd6

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

crates/rust-analyzer/src/op_queue.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,28 +37,39 @@ impl<Args, Output: Default> Default for OpQueue<Args, Output> {
3737
}
3838

3939
impl<Args, Output> OpQueue<Args, Output> {
40+
/// Request an operation to start.
4041
pub(crate) fn request_op(&mut self, reason: Cause, args: Args) {
4142
self.op_requested = Some((reason, args));
4243
}
44+
45+
/// If there was an operation requested, mark this queue as
46+
/// started and return the request arguments.
4347
pub(crate) fn should_start_op(&mut self) -> Option<(Cause, Args)> {
4448
if self.op_in_progress {
4549
return None;
4650
}
4751
self.op_in_progress = self.op_requested.is_some();
4852
self.op_requested.take()
4953
}
54+
55+
/// Mark an operation as completed.
5056
pub(crate) fn op_completed(&mut self, result: Output) {
5157
assert!(self.op_in_progress);
5258
self.op_in_progress = false;
5359
self.last_op_result = result;
5460
}
5561

62+
/// Get the result of the last operation.
5663
pub(crate) fn last_op_result(&self) -> &Output {
5764
&self.last_op_result
5865
}
66+
67+
// Is there an operation that has started, but hasn't yet finished?
5968
pub(crate) fn op_in_progress(&self) -> bool {
6069
self.op_in_progress
6170
}
71+
72+
// Has an operation been requested?
6273
pub(crate) fn op_requested(&self) -> bool {
6374
self.op_requested.is_some()
6475
}

0 commit comments

Comments
 (0)