Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1ee8f4d2 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "aconfig: remove unnecessary clones" into main

parents 4afc5d7b b5133f6a
Loading
Loading
Loading
Loading
+8 −8
Original line number Diff line number Diff line
@@ -38,9 +38,9 @@ where
    let cpp_namespace = package.replace('.', "::");
    ensure!(codegen::is_valid_name_ident(&header));
    let context = Context {
        header: header.clone(),
        cpp_namespace,
        package: package.to_string(),
        header: &header,
        cpp_namespace: &cpp_namespace,
        package,
        readwrite,
        for_test: codegen_mode == CodegenMode::Test,
        class_elements,
@@ -77,10 +77,10 @@ pub struct FileSpec<'a> {
}

#[derive(Serialize)]
pub struct Context {
    pub header: String,
    pub cpp_namespace: String,
    pub package: String,
pub struct Context<'a> {
    pub header: &'a str,
    pub cpp_namespace: &'a str,
    pub package: &'a str,
    pub readwrite: bool,
    pub for_test: bool,
    pub class_elements: Vec<ClassElement>,
@@ -517,7 +517,7 @@ void com_android_aconfig_test_reset_flags() {
        for file in generated {
            generated_files_map.insert(
                String::from(file.path.to_str().unwrap()),
                String::from_utf8(file.contents.clone()).unwrap(),
                String::from_utf8(file.contents).unwrap(),
            );
        }

+2 −2
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ mod tests {
                None,
                crate::test::first_significant_code_diff(
                    file_set.get(file_path).unwrap(),
                    &String::from_utf8(file.contents.clone()).unwrap()
                    &String::from_utf8(file.contents).unwrap()
                ),
                "File {} content is not correct",
                file_path
@@ -362,7 +362,7 @@ mod tests {
                None,
                crate::test::first_significant_code_diff(
                    file_set.get(file_path).unwrap(),
                    &String::from_utf8(file.contents.clone()).unwrap()
                    &String::from_utf8(file.contents).unwrap()
                ),
                "File {} content is not correct",
                file_path
+3 −3
Original line number Diff line number Diff line
@@ -137,14 +137,14 @@ fn open_single_file(matches: &ArgMatches, arg_name: &str) -> Result<Input> {
}

fn write_output_file_realtive_to_dir(root: &Path, output_file: &OutputFile) -> Result<()> {
    let path = root.join(output_file.path.clone());
    let path = root.join(&output_file.path);
    let parent = path
        .parent()
        .ok_or(anyhow!("unable to locate parent of output file {}", path.display()))?;
    fs::create_dir_all(parent)
        .with_context(|| format!("failed to create directory {}", parent.display()))?;
    let mut file = fs::File::create(path.clone())
        .with_context(|| format!("failed to open {}", path.display()))?;
    let mut file =
        fs::File::create(&path).with_context(|| format!("failed to open {}", path.display()))?;
    file.write_all(&output_file.contents)
        .with_context(|| format!("failed to write to {}", path.display()))?;
    Ok(())