mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Auto merge of #9183 - weihanglo:refactor/straighforward-deref, r=alexcrichton
refactor: make deref intentions more straightforward Just some little tweaks to make intentions of deref more straightforward.
This commit is contained in:
commit
adb35807a3
@ -285,7 +285,7 @@ impl ser::Serialize for Target {
|
||||
edition: &self.edition().to_string(),
|
||||
required_features: self
|
||||
.required_features()
|
||||
.map(|rf| rf.iter().map(|s| &**s).collect()),
|
||||
.map(|rf| rf.iter().map(|s| s.as_str()).collect()),
|
||||
doc: self.documented(),
|
||||
doctest: self.doctested() && self.doctestable(),
|
||||
test: self.tested(),
|
||||
|
@ -271,20 +271,12 @@ impl<'src> SourceMap<'src> {
|
||||
|
||||
/// Like `HashMap::get`.
|
||||
pub fn get(&self, id: SourceId) -> Option<&(dyn Source + 'src)> {
|
||||
let source = self.map.get(&id);
|
||||
|
||||
source.map(|s| {
|
||||
let s: &(dyn Source + 'src) = &**s;
|
||||
s
|
||||
})
|
||||
self.map.get(&id).map(|s| s.as_ref())
|
||||
}
|
||||
|
||||
/// Like `HashMap::get_mut`.
|
||||
pub fn get_mut(&mut self, id: SourceId) -> Option<&mut (dyn Source + 'src)> {
|
||||
self.map.get_mut(&id).map(|s| {
|
||||
let s: &mut (dyn Source + 'src) = &mut **s;
|
||||
s
|
||||
})
|
||||
self.map.get_mut(&id).map(|s| s.as_mut())
|
||||
}
|
||||
|
||||
/// Like `HashMap::get`, but first calculates the `SourceId` from a `PackageId`.
|
||||
|
@ -96,7 +96,7 @@ fn resolve_to_string_orig(
|
||||
f.read_to_string(&mut s)?;
|
||||
Ok(s)
|
||||
});
|
||||
let out = serialize_resolve(resolve, orig.as_ref().ok().map(|s| &**s));
|
||||
let out = serialize_resolve(resolve, orig.as_deref().ok());
|
||||
(orig.ok(), out, ws_root)
|
||||
}
|
||||
|
||||
|
@ -74,10 +74,7 @@ fn sync(
|
||||
opts: &VendorOptions<'_>,
|
||||
) -> CargoResult<VendorConfig> {
|
||||
let canonical_destination = opts.destination.canonicalize();
|
||||
let canonical_destination = canonical_destination
|
||||
.as_ref()
|
||||
.map(|p| &**p)
|
||||
.unwrap_or(opts.destination);
|
||||
let canonical_destination = canonical_destination.as_deref().unwrap_or(opts.destination);
|
||||
|
||||
paths::create_dir_all(&canonical_destination)?;
|
||||
let mut to_remove = HashSet::new();
|
||||
|
Loading…
x
Reference in New Issue
Block a user