Skip to content

Commit

Permalink
Update to rust 1.83
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr committed Dec 1, 2024
1 parent 56cbcd2 commit 0baffbb
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
18 changes: 9 additions & 9 deletions src/course_library.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,12 @@ impl LocalCourseLibrary {
index_writer: &mut IndexWriter,
id: Ustr,
name: &str,
description: &Option<String>,
metadata: &Option<BTreeMap<String, Vec<String>>>,
description: Option<&str>,
metadata: Option<&BTreeMap<String, Vec<String>>>,
) -> Result<()> {
// Extract the description from the `Option` value to satisfy the borrow checker.
let empty = String::new();
let description = description.as_ref().unwrap_or(&empty);
let description = description.unwrap_or(&empty);

// Declare the base document with the ID, name, and description fields.
let mut doc = doc!(
Expand Down Expand Up @@ -229,8 +229,8 @@ impl LocalCourseLibrary {
index_writer,
exercise_manifest.id,
&exercise_manifest.name,
&exercise_manifest.description,
&None,
exercise_manifest.description.as_deref(),
None,
)?; // grcov-excl-line

// Add the exercise to the unit graph and exercise map.
Expand Down Expand Up @@ -328,8 +328,8 @@ impl LocalCourseLibrary {
index_writer,
lesson_manifest.id,
&lesson_manifest.name,
&lesson_manifest.description,
&lesson_manifest.metadata,
lesson_manifest.description.as_deref(),
lesson_manifest.metadata.as_ref(),
)?; // grcov-excl-line
Ok(())
}
Expand Down Expand Up @@ -427,8 +427,8 @@ impl LocalCourseLibrary {
index_writer,
course_manifest.id,
&course_manifest.name,
&course_manifest.description,
&course_manifest.metadata,
course_manifest.description.as_deref(),
course_manifest.metadata.as_ref(),
)?; // grcov-excl-line
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/data/course_generator/transcription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -796,11 +796,11 @@ impl TranscriptionConfig {
/// Takes the current course metadata as input and returns updated metadata with information
/// about the transcription course.
fn generate_course_metadata(
metadata: &Option<BTreeMap<String, Vec<String>>>,
metadata: Option<&BTreeMap<String, Vec<String>>>,
passages: &[TranscriptionPassages],
) -> BTreeMap<String, Vec<String>> {
// Insert metadata to indicate this is a transcription course.
let mut metadata = metadata.clone().unwrap_or_default();
let mut metadata = metadata.cloned().unwrap_or_default();
metadata.insert(COURSE_METADATA.to_string(), vec!["true".to_string()]);

// Insert metadata to add all the artists from the passages.
Expand Down Expand Up @@ -857,7 +857,7 @@ impl GenerateManifests for TranscriptionConfig {
let lessons = self.generate_lesson_manifests(course_manifest, preferences, &passages);

// Update the course's metadata and instructions.
let metadata = Self::generate_course_metadata(&course_manifest.metadata, &passages);
let metadata = Self::generate_course_metadata(course_manifest.metadata.as_ref(), &passages);
let instructions = if course_manifest.course_instructions.is_none() {
Some(BasicAsset::InlinedUniqueAsset {
content: *COURSE_INSTRUCTIONS,
Expand Down
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Trane {
impl Trane {
/// Creates the scheduler options, overriding any values with those specified in the user
/// preferences.
fn create_scheduler_options(preferences: &Option<SchedulerPreferences>) -> SchedulerOptions {
fn create_scheduler_options(preferences: Option<&SchedulerPreferences>) -> SchedulerOptions {
let mut options = SchedulerOptions::default();
if let Some(preferences) = preferences {
if let Some(batch_size) = preferences.batch_size {
Expand Down Expand Up @@ -278,7 +278,7 @@ impl Trane {
let repo_manager = Arc::new(RwLock::new(LocalRepositoryManager::new(library_root)?));
let mut mantra_miner = TraneMantraMiner::default();
mantra_miner.mantra_miner.start()?;
let options = Self::create_scheduler_options(&user_preferences.scheduler);
let options = Self::create_scheduler_options(user_preferences.scheduler.as_ref());
options.verify()?;
let scheduler_data = SchedulerData {
options,
Expand Down Expand Up @@ -817,7 +817,7 @@ mod test {
transcription: None,
ignored_paths: vec![],
};
let options = Trane::create_scheduler_options(&user_preferences.scheduler);
let options = Trane::create_scheduler_options(user_preferences.scheduler.as_ref());
assert_eq!(options.batch_size, SchedulerOptions::default().batch_size);

// Test with preferences.
Expand All @@ -828,7 +828,7 @@ mod test {
transcription: None,
ignored_paths: vec![],
};
let options = Trane::create_scheduler_options(&user_preferences.scheduler);
let options = Trane::create_scheduler_options(user_preferences.scheduler.as_ref());
assert_eq!(options.batch_size, 10);
}
}

0 comments on commit 0baffbb

Please sign in to comment.