@@ -62,8 +62,38 @@ pub trait Locator: Send + Sync {
6262 /// Returns the name of the locator.
6363 fn get_kind ( & self ) -> LocatorKind ;
6464 /// Configures the locator with the given configuration.
65- /// Override this method if you need to have some custom configuration.
66- /// E.g. storing some of the configuration information in the locator.
65+ ///
66+ /// Override this method if you need to store configuration in the locator.
67+ ///
68+ /// # Why `&self` instead of `&mut self`?
69+ ///
70+ /// Locators are shared across threads via `Arc<dyn Locator>` and may be
71+ /// configured while other operations are in progress. Using `&self` allows
72+ /// concurrent access without requiring the caller to hold an exclusive lock
73+ /// on the entire locator.
74+ ///
75+ /// Implementations that need to store configuration should use interior
76+ /// mutability (e.g., `Mutex<T>` or `RwLock<T>`) for the mutable fields only.
77+ ///
78+ /// # Example
79+ ///
80+ /// ```ignore
81+ /// use std::sync::Mutex;
82+ /// use std::path::PathBuf;
83+ ///
84+ /// struct MyLocator {
85+ /// workspace_dirs: Mutex<Vec<PathBuf>>,
86+ /// }
87+ ///
88+ /// impl Locator for MyLocator {
89+ /// fn configure(&self, config: &Configuration) {
90+ /// if let Some(dirs) = &config.workspace_directories {
91+ /// *self.workspace_dirs.lock().unwrap() = dirs.clone();
92+ /// }
93+ /// }
94+ /// // ... other required methods
95+ /// }
96+ /// ```
6797 fn configure ( & self , _config : & Configuration ) {
6898 //
6999 }
0 commit comments