Repository: bevyengine/bevy
File: crates/bevy_image/src/image.rs (Rust)

Code before:

impl ImageSamplerDescriptor {
    /// Returns a sampler descriptor with [`Linear`](ImageFilterMode::Linear) min and mag filters
    #[inline]
    pub fn linear() -> ImageSamplerDescriptor {
        ImageSamplerDescriptor {
            mag_filter: ImageFilterMode::Linear,
            min_filter: ImageFilterMode::Linear,
            mipmap_filter: ImageFilterMode::Linear,
            ..Default::default()
        }
    }

    /// Returns a sampler descriptor with [`Nearest`](ImageFilterMode::Nearest) min and mag filters
    #[inline]
    pub fn nearest() -> ImageSamplerDescriptor {
        ImageSamplerDescriptor {
            mag_filter: ImageFilterMode::Nearest,
            min_filter: ImageFilterMode::Nearest,
            mipmap_filter: ImageFilterMode::Nearest,
            ..Default::default()
        }
    }

    /// Returns this sampler descriptor with a new `ImageFilterMode` min, mag, and mipmap filters
    #[inline]
    pub fn with_filter(&mut self, filter: ImageFilterMode) -> &mut Self {
        self.mag_filter = filter;
        self.min_filter = filter;
        self.mipmap_filter = filter;
        self
    }

    /// Returns this sampler descriptor with a new `ImageAddressMode` for u, v, and w
    #[inline]
    pub fn with_address_mode(&mut self, address_mode: ImageAddressMode) -> &mut Self {
        self.address_mode_u = address_mode;
        self.address_mode_v = address_mode;
        self.address_mode_w = address_mode;
        self
    }

    pub fn as_wgpu(&self) -> SamplerDescriptor<Option<&str>> {
        SamplerDescriptor {
            label: self.label.as_deref(),
            address_mode_u: self.address_mode_u.into(),
            address_mode_v: self.address_mode_v.into(),
            address_mode_w: self.address_mode_w.into(),
            mag_filter: self.mag_filter.into(),
            min_filter: self.min_filter.into(),
            mipmap_filter: self.mipmap_filter.into(),

Review comment (suggestion):
```suggestion
```

I don't think inline is appropriate here. I respect that some other functions in the struct are inline, but they're probably from the olden days when inline was more necessary.

Code after:

impl ImageSamplerDescriptor {
    /// Returns a sampler descriptor with [`Linear`](ImageFilterMode::Linear) min and mag filters
    #[inline]
    pub fn linear() -> ImageSamplerDescriptor {
        ImageSamplerDescriptor {
            mag_filter: ImageFilterMode::Linear,
            min_filter: ImageFilterMode::Linear,
            mipmap_filter: ImageFilterMode::Linear,
            ..Default::default()
        }
    }

    /// Returns a sampler descriptor with [`Nearest`](ImageFilterMode::Nearest) min and mag filters
    #[inline]
    pub fn nearest() -> ImageSamplerDescriptor {
        ImageSamplerDescriptor {
            mag_filter: ImageFilterMode::Nearest,
            min_filter: ImageFilterMode::Nearest,
            mipmap_filter: ImageFilterMode::Nearest,
            ..Default::default()
        }
    }

    /// Returns this sampler descriptor with a new `ImageFilterMode` min, mag, and mipmap filters
    #[inline]
    pub fn set_filter(&mut self, filter: ImageFilterMode) -> &mut Self {
        self.mag_filter = filter;
        self.min_filter = filter;
        self.mipmap_filter = filter;
        self
    }

    /// Returns this sampler descriptor with a new `ImageAddressMode` for u, v, and w
    #[inline]
    pub fn set_address_mode(&mut self, address_mode: ImageAddressMode) -> &mut Self {
        self.address_mode_u = address_mode;
        self.address_mode_v = address_mode;
        self.address_mode_w = address_mode;
        self
    }

    /// Returns this sampler descriptor with an `anisotropy_clamp` value and also
    /// set filters to `ImageFilterMode::Linear`, which is required to
    /// use anisotropy.
    #[inline]
    pub fn set_anisotropic_filter(&mut self, anisotropy_clamp: u16) -> &mut Self {
        self.mag_filter = ImageFilterMode::Linear;
        self.min_filter = ImageFilterMode::Linear;
        self.mipmap_filter = ImageFilterMode::Linear;
        self.anisotropy_clamp = anisotropy_clamp;