从带有if循环的函数返回自定义类型时,返回类型错误

时间:2020-07-22 17:22:36

标签: rust

我正在将Devon Crawford's time-lapse plugin从Java移植到Rust。

我的问题与proRaw.java文件和getPrevImage方法有关

public Image getPrevImage(Image currIMG) {
    return images.get(currIMG.getListNum() - 1);
}

这是我的Rust版本:

pub fn get_previous_image(current: Image, p: PhotoXMP) -> Image {
    let v = p.image_sequence.into_iter();
    for x in v {
        if x.xmp_path == current.xmp_path
            && x.image_path == current.image_path
            && x.exposure == current.exposure
            && x.aperture == current.aperture
            && x.iso == current.iso
            && x.list == current.list
            && x.white_balance == current.white_balance
            && x.ratio == current.ratio
            && x.shutter == current.shutter
        {
            return x;
        }
    }
}

#[derive(Clone, Eq, PartialEq)]
pub struct Image {
    xmp_path: String,
    image_path: String,
    iso: i32,
    list: u32,
    white_balance: u32,
    ratio: u64,
    aperture: u64,
    shutter: u64,
    exposure: u64,
}

pub struct PhotoXMP {
    util: Util,
    image_sequence: Vec<Image>,
    exposure_sequence: Vec<ExposeChange>,
    temperature_sequence: Vec<TempChange>,
    exposure_increment: i64,
    start: i32,
    end: i32,
}

getPrevImage方法上,编译器给出错误“预期结构'Image',找到'()'

如果有人要查看它并建议编辑和更改https://github.com/AlvinKuruvilla/PhotoXMP

,请点击此处,链接到GitHub库。

0 个答案:

没有答案