mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Fix typos in ARCHITECTURE.md and a number of crates
specifically: gen_lsp_server, ra_arena, ra_cli, ra_db, ra_hir
This commit is contained in:
parent
f8261d611a
commit
0b8fbb4fad
23 changed files with 150 additions and 91 deletions
44
crates/ra_db/src/cancellation.rs
Normal file
44
crates/ra_db/src/cancellation.rs
Normal file
|
@ -0,0 +1,44 @@
|
|||
//! Utility types to support cancellation.
|
||||
//!
|
||||
//! In a typical IDE use-case, requests and modification happen concurrently, as
|
||||
//! in the following scenario:
|
||||
//!
|
||||
//! * user types a character,
|
||||
//! * a syntax highlighting process is started
|
||||
//! * user types next character, while syntax highlighting *is still in
|
||||
//! progress*.
|
||||
//!
|
||||
//! In this situation, we want to react to modification as quickly as possible.
|
||||
//! At the same time, in-progress results are not very interesting, because they
|
||||
//! are invalidated by the edit anyway. So, we first cancel all in-flight
|
||||
//! requests, and then apply modification knowing that it won't interfere with
|
||||
//! any background processing (this bit is handled by salsa, see the
|
||||
//! `BaseDatabase::check_canceled` method).
|
||||
|
||||
/// An "error" signifing that the operation was canceled.
|
||||
#[derive(Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Canceled {
|
||||
_private: (),
|
||||
}
|
||||
|
||||
pub type Cancelable<T> = Result<T, Canceled>;
|
||||
|
||||
impl Canceled {
|
||||
pub(crate) fn new() -> Canceled {
|
||||
Canceled { _private: () }
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Canceled {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
fmt.write_str("canceled")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Canceled {
|
||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
write!(fmt, "Canceled")
|
||||
}
|
||||
}
|
||||
|
||||
impl std::error::Error for Canceled {}
|
Loading…
Add table
Add a link
Reference in a new issue