This commit is contained in:
Gary Yendell 2025-12-16 16:40:21 -05:00 committed by GitHub
commit c19d6d3bc6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 16 additions and 0 deletions

View File

@ -1,14 +1,30 @@
use std::collections::HashMap; use std::collections::HashMap;
use std::sync::LazyLock; use std::sync::LazyLock;
use crate::warn_user_once;
const DEPRECATED_SELECTORS: [&str; 3] = ["R", "U", "IC"];
fn check_for_deprecation(code: &str) {
if DEPRECATED_SELECTORS.contains(&code) {
warn_user_once!(
"Using `{code}` as a selector is deprecated and will be removed in a future version."
);
}
}
/// Returns the redirect target for the given code. /// Returns the redirect target for the given code.
pub(crate) fn get_redirect_target(code: &str) -> Option<&'static str> { pub(crate) fn get_redirect_target(code: &str) -> Option<&'static str> {
check_for_deprecation(code);
REDIRECTS.get(code).copied() REDIRECTS.get(code).copied()
} }
/// Returns the code and the redirect target if the given code is a redirect. /// Returns the code and the redirect target if the given code is a redirect.
/// (The same code is returned to obtain it with a static lifetime). /// (The same code is returned to obtain it with a static lifetime).
pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> { pub(crate) fn get_redirect(code: &str) -> Option<(&'static str, &'static str)> {
check_for_deprecation(code);
REDIRECTS.get_key_value(code).map(|(k, v)| (*k, *v)) REDIRECTS.get_key_value(code).map(|(k, v)| (*k, *v))
} }