Skip to content

Commit

Permalink
rename CandidateVersion::new to CandidateVersion::new_remote
Browse files Browse the repository at this point in the history
  • Loading branch information
gerdreiss committed Oct 25, 2021
1 parent a2129fe commit e5e629e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
6 changes: 1 addition & 5 deletions api/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,7 @@ pub fn retrieve_local_candidates() -> std::io::Result<Vec<LocalCandidate>> {
);
if version_dir_name != "current" {
let other_version = Version::OtherVersion(version_dir_name);
candidate_versions.push(CandidateVersion::new_local(
other_version,
true,
false,
));
candidate_versions.push(CandidateVersion::new_local(other_version, false));
}
}
local_versions.push(LocalCandidate::new(
Expand Down
14 changes: 7 additions & 7 deletions api/src/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,17 @@ pub struct RemoteCandidate {
}

impl CandidateVersion {
pub fn new(version: Version) -> Self {
pub fn new_remote(version: Version) -> Self {
Self {
version,
installed: false,
current: false,
}
}
pub fn new_local(version: Version, installed: bool, current: bool) -> Self {
pub fn new_local(version: Version, current: bool) -> Self {
Self {
version,
installed,
installed: true,
current,
}
}
Expand All @@ -68,8 +68,8 @@ impl CandidateVersion {
impl LocalCandidate {
pub fn new(binary_name: String, versions: Vec<CandidateVersion>) -> Self {
Self {
binary_name: binary_name,
versions: versions,
binary_name,
versions,
}
}
pub fn binary_name(&self) -> &String {
Expand Down Expand Up @@ -150,8 +150,8 @@ impl ToString for CandidateVersion {
}
Version::OtherVersion(value) => format!(
" {} {} {} ",
if self.current { ">" } else { "" },
if self.installed { "*" } else { "" },
if self.current { ">" } else { " " },
if self.installed { "*" } else { " " },
value
),
}
Expand Down
4 changes: 2 additions & 2 deletions api/src/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ fn parse_available_versions(input: &String) -> Vec<CandidateVersion> {
strs.sort_by(|s1, s2| alphanumeric_sort::compare_str(s2, s1));
strs.iter()
.map(|v| Version::from_str(v).unwrap())
.map(|v| CandidateVersion::new(v))
.map(|v| CandidateVersion::new_remote(v))
.collect()
}
}
Expand All @@ -119,6 +119,6 @@ fn parse_available_java_versions(input: &String) -> Vec<CandidateVersion> {
.skip(5)
.take_while(|line| !line.starts_with("==="))
.map(|line| Version::from_str(line).unwrap())
.map(|version| CandidateVersion::new(version))
.map(|version| CandidateVersion::new_remote(version))
.collect()
}
4 changes: 2 additions & 2 deletions ui/src/candidates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl SdkmanApp {
Candidate::from_model(
remote_candidate,
local_candidates.iter().find(|local_candidate| {
remote_candidate.binary_name() == local_candidate.binary_name()
*remote_candidate.binary_name() == *local_candidate.binary_name()
}),
)
})
Expand Down Expand Up @@ -242,7 +242,7 @@ impl SdkmanApp {
selected_candidate,
candidate_search_dialog,
candidate_search_term,
error_message
error_message,
);
}

Expand Down

0 comments on commit e5e629e

Please sign in to comment.