Use built-in [lints] table in Cargo.toml

This commit is contained in:
Héctor Ramón Jiménez 2024-04-07 12:42:12 +02:00
parent a865b38002
commit 5cd98f069d
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
32 changed files with 274 additions and 244 deletions

View file

@ -1,53 +1,2 @@
[alias]
lint = """
clippy --workspace --no-deps -- \
-D warnings \
-A clippy::type_complexity \
-D clippy::semicolon_if_nothing_returned \
-D clippy::trivially-copy-pass-by-ref \
-D clippy::default_trait_access \
-D clippy::match-wildcard-for-single-variants \
-D clippy::redundant-closure-for-method-calls \
-D clippy::filter_map_next \
-D clippy::manual_let_else \
-D clippy::unused_async \
-D clippy::from_over_into \
-D clippy::needless_borrow \
-D clippy::new_without_default \
-D clippy::useless_conversion
"""
nitpick = """
clippy --workspace --no-deps -- \
-D warnings \
-D clippy::pedantic \
-A clippy::type_complexity \
-A clippy::must_use_candidate \
-A clippy::return_self_not_must_use \
-A clippy::needless_pass_by_value \
-A clippy::cast_precision_loss \
-A clippy::cast_sign_loss \
-A clippy::cast_possible_truncation \
-A clippy::match_same_arms \
-A clippy::missing-errors-doc \
-A clippy::missing-panics-doc \
-A clippy::cast_lossless \
-A clippy::doc_markdown \
-A clippy::items_after_statements \
-A clippy::too_many_lines \
-A clippy::module_name_repetitions \
-A clippy::if_not_else \
-A clippy::redundant_else \
-A clippy::used_underscore_binding \
-A clippy::cast_possible_wrap \
-A clippy::unnecessary_wraps \
-A clippy::struct-excessive-bools \
-A clippy::float-cmp \
-A clippy::single_match_else \
-A clippy::unreadable_literal \
-A clippy::explicit_deref_methods \
-A clippy::map_unwrap_or \
-A clippy::unnested_or_patterns \
-A clippy::similar_names \
-A clippy::unused_self
"""
lint = "clippy --workspace --no-deps -- -D warnings"

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
@ -74,6 +77,15 @@ thiserror.workspace = true
image.workspace = true
image.optional = true
[dev-dependencies]
criterion = "0.5"
iced_wgpu.workspace = true
[[bench]]
name = "wgpu"
harness = false
required-features = ["canvas"]
[profile.release-opt]
inherits = "release"
codegen-units = 1
@ -165,11 +177,27 @@ winapi = "0.3"
window_clipboard = "0.4.1"
winit = { git = "https://github.com/iced-rs/winit.git", rev = "592bd152f6d5786fae7d918532d7db752c0d164f" }
[dev-dependencies]
criterion = "0.5"
iced_wgpu.workspace = true
[workspace.lints.rust]
rust_2018_idioms = "forbid"
missing_debug_implementations = "deny"
missing_docs = "deny"
unsafe_code = "deny"
unused_results = "deny"
[[bench]]
name = "wgpu"
harness = false
required-features = ["canvas"]
[workspace.lints.clippy]
type-complexity = "allow"
semicolon_if_nothing_returned = "deny"
trivially-copy-pass-by-ref = "deny"
default_trait_access = "deny"
match-wildcard-for-single-variants = "deny"
redundant-closure-for-method-calls = "deny"
filter_map_next = "deny"
manual_let_else = "deny"
unused_async = "deny"
from_over_into = "deny"
needless_borrow = "deny"
new_without_default = "deny"
useless_conversion = "deny"
[workspace.lints.rustdoc]
broken_intra_doc_links = "forbid"

View file

@ -1,3 +1,4 @@
#![allow(missing_docs)]
use criterion::{criterion_group, criterion_main, Bencher, Criterion};
use iced::alignment;
@ -12,8 +13,12 @@ criterion_main!(benches);
criterion_group!(benches, wgpu_benchmark);
pub fn wgpu_benchmark(c: &mut Criterion) {
c.bench_function("wgpu — canvas (light)", |b| benchmark(b, scene(10)));
c.bench_function("wgpu — canvas (heavy)", |b| benchmark(b, scene(1_000)));
let _ = c
.bench_function("wgpu — canvas (light)", |b| benchmark(b, scene(10)));
let _ = c.bench_function("wgpu — canvas (heavy)", |b| {
benchmark(b, scene(1_000))
});
}
fn benchmark<'a>(
@ -98,7 +103,7 @@ fn benchmark<'a>(
);
bencher.iter(|| {
user_interface.draw(
let _ = user_interface.draw(
&mut renderer,
&Theme::Dark,
&core::renderer::Style {

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[features]
auto-detect-theme = ["dep:dark-light"]
advanced = []

View file

@ -9,13 +9,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
rustdoc::broken_intra_doc_links
)]
pub mod alignment;
pub mod border;
pub mod clipboard;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true

View file

@ -4,13 +4,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use futures;
pub use iced_core as core;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true

View file

@ -7,14 +7,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unsafe_code,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
mod antialiasing;
mod cached;

View file

@ -7,8 +7,7 @@ use std::collections::hash_map;
use std::hash::{Hash, Hasher};
/// A store of recently used sections of text.
#[allow(missing_debug_implementations)]
#[derive(Default)]
#[derive(Debug, Default)]
pub struct Cache {
entries: FxHashMap<KeyHash, Entry>,
aliases: FxHashMap<KeyHash, KeyHash>,
@ -135,7 +134,7 @@ impl Key<'_> {
pub type KeyHash = u64;
/// A cache entry.
#[allow(missing_debug_implementations)]
#[derive(Debug)]
pub struct Entry {
/// The buffer of text, ready for drawing.
pub buffer: cosmic_text::Buffer,

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[dependencies]
iced_core.workspace = true

View file

@ -1,3 +1,4 @@
//! A syntax highlighter for iced.
use iced_core as core;
use crate::core::text::highlighter::{self, Format};
@ -16,6 +17,8 @@ static THEMES: Lazy<highlighting::ThemeSet> =
const LINES_PER_SNAPSHOT: usize = 50;
/// A syntax highlighter.
#[derive(Debug)]
pub struct Highlighter {
syntax: &'static parsing::SyntaxReference,
highlighter: highlighting::Highlighter<'static>,
@ -131,25 +134,47 @@ impl highlighter::Highlighter for Highlighter {
}
}
/// The settings of a [`Highlighter`].
#[derive(Debug, Clone, PartialEq)]
pub struct Settings {
/// The [`Theme`] of the [`Highlighter`].
///
/// It dictates the color scheme that will be used for highlighting.
pub theme: Theme,
/// The extension of the file to highlight.
///
/// The [`Highlighter`] will use the extension to automatically determine
/// the grammar to use for highlighting.
pub extension: String,
}
/// A highlight produced by a [`Highlighter`].
#[derive(Debug)]
pub struct Highlight(highlighting::StyleModifier);
impl Highlight {
/// Returns the color of this [`Highlight`].
///
/// If `None`, the original text color should be unchanged.
pub fn color(&self) -> Option<Color> {
self.0.foreground.map(|color| {
Color::from_rgba8(color.r, color.g, color.b, color.a as f32 / 255.0)
})
}
/// Returns the font of this [`Highlight`].
///
/// If `None`, the original font should be unchanged.
pub fn font(&self) -> Option<Font> {
None
}
/// Returns the [`Format`] of the [`Highlight`].
///
/// It contains both the [`color`] and the [`font`].
///
/// [`color`]: Self::color
/// [`font`]: Self::font
pub fn to_format(&self) -> Format<Font> {
Format {
color: self.color(),
@ -158,6 +183,8 @@ impl Highlight {
}
}
/// A highlighting theme.
#[allow(missing_docs)]
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Theme {
SolarizedDark,
@ -168,6 +195,7 @@ pub enum Theme {
}
impl Theme {
/// A static slice containing all the available themes.
pub const ALL: &'static [Self] = &[
Self::SolarizedDark,
Self::Base16Mocha,
@ -176,6 +204,7 @@ impl Theme {
Self::InspiredGitHub,
];
/// Returns `true` if the [`Theme`] is dark, and false otherwise.
pub fn is_dark(self) -> bool {
match self {
Self::SolarizedDark
@ -209,7 +238,7 @@ impl std::fmt::Display for Theme {
}
}
pub struct ScopeRangeIterator {
struct ScopeRangeIterator {
ops: Vec<(usize, parsing::ScopeStackOp)>,
line_length: usize,
index: usize,

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[features]
wgpu = ["iced_wgpu"]
tiny-skia = ["iced_tiny_skia"]

View file

@ -1,3 +1,4 @@
//! Compose existing renderers and create type-safe fallback strategies.
use crate::core::image;
use crate::core::renderer;
use crate::core::svg;
@ -8,24 +9,31 @@ use crate::graphics;
use crate::graphics::compositor;
use crate::graphics::mesh;
pub enum Renderer<L, R> {
Left(L),
Right(R),
/// A renderer `A` with a fallback strategy `B`.
///
/// This type can be used to easily compose existing renderers and
/// create custom, type-safe fallback strategies.
#[derive(Debug)]
pub enum Renderer<A, B> {
/// The primary rendering option.
Primary(A),
/// The secondary (or fallback) rendering option.
Secondary(B),
}
macro_rules! delegate {
($renderer:expr, $name:ident, $body:expr) => {
match $renderer {
Self::Left($name) => $body,
Self::Right($name) => $body,
Self::Primary($name) => $body,
Self::Secondary($name) => $body,
}
};
}
impl<L, R> core::Renderer for Renderer<L, R>
impl<A, B> core::Renderer for Renderer<A, B>
where
L: core::Renderer,
R: core::Renderer,
A: core::Renderer,
B: core::Renderer,
{
fn fill_quad(
&mut self,
@ -56,22 +64,22 @@ where
}
}
impl<L, R> core::text::Renderer for Renderer<L, R>
impl<A, B> core::text::Renderer for Renderer<A, B>
where
L: core::text::Renderer,
R: core::text::Renderer<
Font = L::Font,
Paragraph = L::Paragraph,
Editor = L::Editor,
A: core::text::Renderer,
B: core::text::Renderer<
Font = A::Font,
Paragraph = A::Paragraph,
Editor = A::Editor,
>,
{
type Font = L::Font;
type Paragraph = L::Paragraph;
type Editor = L::Editor;
type Font = A::Font;
type Paragraph = A::Paragraph;
type Editor = A::Editor;
const ICON_FONT: Self::Font = L::ICON_FONT;
const CHECKMARK_ICON: char = L::CHECKMARK_ICON;
const ARROW_DOWN_ICON: char = L::ARROW_DOWN_ICON;
const ICON_FONT: Self::Font = A::ICON_FONT;
const CHECKMARK_ICON: char = A::CHECKMARK_ICON;
const ARROW_DOWN_ICON: char = A::ARROW_DOWN_ICON;
fn default_font(&self) -> Self::Font {
delegate!(self, renderer, renderer.default_font())
@ -128,12 +136,12 @@ where
}
}
impl<L, R> image::Renderer for Renderer<L, R>
impl<A, B> image::Renderer for Renderer<A, B>
where
L: image::Renderer,
R: image::Renderer<Handle = L::Handle>,
A: image::Renderer,
B: image::Renderer<Handle = A::Handle>,
{
type Handle = L::Handle;
type Handle = A::Handle;
fn measure_image(&self, handle: &Self::Handle) -> Size<u32> {
delegate!(self, renderer, renderer.measure_image(handle))
@ -153,10 +161,10 @@ where
}
}
impl<L, R> svg::Renderer for Renderer<L, R>
impl<A, B> svg::Renderer for Renderer<A, B>
where
L: svg::Renderer,
R: svg::Renderer,
A: svg::Renderer,
B: svg::Renderer,
{
fn measure_svg(&self, handle: &svg::Handle) -> Size<u32> {
delegate!(self, renderer, renderer.measure_svg(handle))
@ -172,37 +180,49 @@ where
}
}
impl<L, R> mesh::Renderer for Renderer<L, R>
impl<A, B> mesh::Renderer for Renderer<A, B>
where
L: mesh::Renderer,
R: mesh::Renderer,
A: mesh::Renderer,
B: mesh::Renderer,
{
fn draw_mesh(&mut self, mesh: graphics::Mesh) {
delegate!(self, renderer, renderer.draw_mesh(mesh));
}
}
pub enum Compositor<L, R>
/// A compositor `A` with a fallback strategy `B`.
///
/// It works analogously to [`Renderer`].
#[derive(Debug)]
pub enum Compositor<A, B>
where
L: graphics::Compositor,
R: graphics::Compositor,
A: graphics::Compositor,
B: graphics::Compositor,
{
Left(L),
Right(R),
/// The primary compositing option.
Primary(A),
/// The secondary (or fallback) compositing option.
Secondary(B),
}
pub enum Surface<L, R> {
Left(L),
Right(R),
/// A surface `A` with a fallback strategy `B`.
///
/// It works analogously to [`Renderer`].
#[derive(Debug)]
pub enum Surface<A, B> {
/// The primary surface option.
Primary(A),
/// The secondary (or fallback) surface option.
Secondary(B),
}
impl<L, R> graphics::Compositor for Compositor<L, R>
impl<A, B> graphics::Compositor for Compositor<A, B>
where
L: graphics::Compositor,
R: graphics::Compositor,
A: graphics::Compositor,
B: graphics::Compositor,
{
type Renderer = Renderer<L::Renderer, R::Renderer>;
type Surface = Surface<L::Surface, R::Surface>;
type Renderer = Renderer<A::Renderer, B::Renderer>;
type Surface = Surface<A::Surface, B::Surface>;
async fn with_backend<W: compositor::Window + Clone>(
settings: graphics::Settings,
@ -233,19 +253,19 @@ where
let mut errors = vec![];
for backend in candidates.iter().map(Option::as_deref) {
match L::with_backend(settings, compatible_window.clone(), backend)
match A::with_backend(settings, compatible_window.clone(), backend)
.await
{
Ok(compositor) => return Ok(Self::Left(compositor)),
Ok(compositor) => return Ok(Self::Primary(compositor)),
Err(error) => {
errors.push(error);
}
}
match R::with_backend(settings, compatible_window.clone(), backend)
match B::with_backend(settings, compatible_window.clone(), backend)
.await
{
Ok(compositor) => return Ok(Self::Right(compositor)),
Ok(compositor) => return Ok(Self::Secondary(compositor)),
Err(error) => {
errors.push(error);
}
@ -257,11 +277,11 @@ where
fn create_renderer(&self) -> Self::Renderer {
match self {
Self::Left(compositor) => {
Renderer::Left(compositor.create_renderer())
Self::Primary(compositor) => {
Renderer::Primary(compositor.create_renderer())
}
Self::Right(compositor) => {
Renderer::Right(compositor.create_renderer())
Self::Secondary(compositor) => {
Renderer::Secondary(compositor.create_renderer())
}
}
}
@ -273,12 +293,12 @@ where
height: u32,
) -> Self::Surface {
match self {
Self::Left(compositor) => {
Surface::Left(compositor.create_surface(window, width, height))
}
Self::Right(compositor) => {
Surface::Right(compositor.create_surface(window, width, height))
}
Self::Primary(compositor) => Surface::Primary(
compositor.create_surface(window, width, height),
),
Self::Secondary(compositor) => Surface::Secondary(
compositor.create_surface(window, width, height),
),
}
}
@ -289,10 +309,10 @@ where
height: u32,
) {
match (self, surface) {
(Self::Left(compositor), Surface::Left(surface)) => {
(Self::Primary(compositor), Surface::Primary(surface)) => {
compositor.configure_surface(surface, width, height);
}
(Self::Right(compositor), Surface::Right(surface)) => {
(Self::Secondary(compositor), Surface::Secondary(surface)) => {
compositor.configure_surface(surface, width, height);
}
_ => unreachable!(),
@ -313,9 +333,9 @@ where
) -> Result<(), compositor::SurfaceError> {
match (self, renderer, surface) {
(
Self::Left(compositor),
Renderer::Left(renderer),
Surface::Left(surface),
Self::Primary(compositor),
Renderer::Primary(renderer),
Surface::Primary(surface),
) => compositor.present(
renderer,
surface,
@ -324,9 +344,9 @@ where
overlay,
),
(
Self::Right(compositor),
Renderer::Right(renderer),
Surface::Right(surface),
Self::Secondary(compositor),
Renderer::Secondary(renderer),
Surface::Secondary(surface),
) => compositor.present(
renderer,
surface,
@ -348,9 +368,9 @@ where
) -> Vec<u8> {
match (self, renderer, surface) {
(
Self::Left(compositor),
Renderer::Left(renderer),
Surface::Left(surface),
Self::Primary(compositor),
Renderer::Primary(renderer),
Surface::Primary(surface),
) => compositor.screenshot(
renderer,
surface,
@ -359,9 +379,9 @@ where
overlay,
),
(
Self::Right(compositor),
Renderer::Right(renderer),
Surface::Right(surface),
Self::Secondary(compositor),
Renderer::Secondary(renderer),
Surface::Secondary(surface),
) => compositor.screenshot(
renderer,
surface,
@ -375,10 +395,10 @@ where
}
#[cfg(feature = "wgpu")]
impl<L, R> iced_wgpu::primitive::pipeline::Renderer for Renderer<L, R>
impl<A, B> iced_wgpu::primitive::pipeline::Renderer for Renderer<A, B>
where
L: iced_wgpu::primitive::pipeline::Renderer,
R: core::Renderer,
A: iced_wgpu::primitive::pipeline::Renderer,
B: core::Renderer,
{
fn draw_pipeline_primitive(
&mut self,
@ -386,10 +406,10 @@ where
primitive: impl iced_wgpu::primitive::pipeline::Primitive,
) {
match self {
Self::Left(renderer) => {
Self::Primary(renderer) => {
renderer.draw_pipeline_primitive(bounds, primitive);
}
Self::Right(_) => {
Self::Secondary(_) => {
log::warn!(
"Custom shader primitive is not supported with this renderer."
);
@ -405,27 +425,31 @@ mod geometry {
use crate::graphics::geometry::{self, Fill, Path, Stroke, Text};
use crate::graphics::Cached;
impl<L, R> geometry::Renderer for Renderer<L, R>
impl<A, B> geometry::Renderer for Renderer<A, B>
where
L: geometry::Renderer,
R: geometry::Renderer,
A: geometry::Renderer,
B: geometry::Renderer,
{
type Geometry = Geometry<L::Geometry, R::Geometry>;
type Frame = Frame<L::Frame, R::Frame>;
type Geometry = Geometry<A::Geometry, B::Geometry>;
type Frame = Frame<A::Frame, B::Frame>;
fn new_frame(&self, size: iced_graphics::core::Size) -> Self::Frame {
match self {
Self::Left(renderer) => Frame::Left(renderer.new_frame(size)),
Self::Right(renderer) => Frame::Right(renderer.new_frame(size)),
Self::Primary(renderer) => {
Frame::Primary(renderer.new_frame(size))
}
Self::Secondary(renderer) => {
Frame::Secondary(renderer.new_frame(size))
}
}
}
fn draw_geometry(&mut self, geometry: Self::Geometry) {
match (self, geometry) {
(Self::Left(renderer), Geometry::Left(geometry)) => {
(Self::Primary(renderer), Geometry::Primary(geometry)) => {
renderer.draw_geometry(geometry);
}
(Self::Right(renderer), Geometry::Right(geometry)) => {
(Self::Secondary(renderer), Geometry::Secondary(geometry)) => {
renderer.draw_geometry(geometry);
}
_ => unreachable!(),
@ -433,44 +457,48 @@ mod geometry {
}
}
pub enum Geometry<L, R> {
Left(L),
Right(R),
#[derive(Debug)]
pub enum Geometry<A, B> {
Primary(A),
Secondary(B),
}
impl<L, R> Cached for Geometry<L, R>
impl<A, B> Cached for Geometry<A, B>
where
L: Cached,
R: Cached,
A: Cached,
B: Cached,
{
type Cache = Geometry<L::Cache, R::Cache>;
type Cache = Geometry<A::Cache, B::Cache>;
fn load(cache: &Self::Cache) -> Self {
match cache {
Geometry::Left(cache) => Self::Left(L::load(cache)),
Geometry::Right(cache) => Self::Right(R::load(cache)),
Geometry::Primary(cache) => Self::Primary(A::load(cache)),
Geometry::Secondary(cache) => Self::Secondary(B::load(cache)),
}
}
fn cache(self) -> Self::Cache {
match self {
Self::Left(geometry) => Geometry::Left(geometry.cache()),
Self::Right(geometry) => Geometry::Right(geometry.cache()),
Self::Primary(geometry) => Geometry::Primary(geometry.cache()),
Self::Secondary(geometry) => {
Geometry::Secondary(geometry.cache())
}
}
}
}
pub enum Frame<L, R> {
Left(L),
Right(R),
#[derive(Debug)]
pub enum Frame<A, B> {
Primary(A),
Secondary(B),
}
impl<L, R> geometry::frame::Backend for Frame<L, R>
impl<A, B> geometry::frame::Backend for Frame<A, B>
where
L: geometry::frame::Backend,
R: geometry::frame::Backend,
A: geometry::frame::Backend,
B: geometry::frame::Backend,
{
type Geometry = Geometry<L::Geometry, R::Geometry>;
type Geometry = Geometry<A::Geometry, B::Geometry>;
fn width(&self) -> f32 {
delegate!(self, frame, frame.width())
@ -519,17 +547,17 @@ mod geometry {
fn draft(&mut self, size: Size) -> Self {
match self {
Self::Left(frame) => Self::Left(frame.draft(size)),
Self::Right(frame) => Self::Right(frame.draft(size)),
Self::Primary(frame) => Self::Primary(frame.draft(size)),
Self::Secondary(frame) => Self::Secondary(frame.draft(size)),
}
}
fn paste(&mut self, frame: Self, at: Point) {
match (self, frame) {
(Self::Left(target), Self::Left(source)) => {
(Self::Primary(target), Self::Primary(source)) => {
target.paste(source, at);
}
(Self::Right(target), Self::Right(source)) => {
(Self::Secondary(target), Self::Secondary(source)) => {
target.paste(source, at);
}
_ => unreachable!(),
@ -554,17 +582,21 @@ mod geometry {
fn into_geometry(self) -> Self::Geometry {
match self {
Frame::Left(frame) => Geometry::Left(frame.into_geometry()),
Frame::Right(frame) => Geometry::Right(frame.into_geometry()),
Frame::Primary(frame) => {
Geometry::Primary(frame.into_geometry())
}
Frame::Secondary(frame) => {
Geometry::Secondary(frame.into_geometry())
}
}
}
}
}
impl<L, R> compositor::Default for Renderer<L, R>
impl<A, B> compositor::Default for Renderer<A, B>
where
L: compositor::Default,
R: compositor::Default,
A: compositor::Default,
B: compositor::Default,
{
type Compositor = Compositor<L::Compositor, R::Compositor>;
type Compositor = Compositor<A::Compositor, B::Compositor>;
}

View file

@ -1,5 +1,4 @@
#![forbid(rust_2018_idioms)]
#![deny(unsafe_code, unused_results, rustdoc::broken_intra_doc_links)]
//! The official renderer for iced.
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#[cfg(feature = "wgpu")]
pub use iced_wgpu as wgpu;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[features]
debug = []
multi-window = []

View file

@ -8,13 +8,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod clipboard;
pub mod command;

View file

@ -165,13 +165,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(rust_2018_idioms, unsafe_code)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
#![cfg_attr(docsrs, feature(doc_cfg))]
use iced_widget::graphics;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[features]
image = ["iced_graphics/image"]
svg = ["resvg"]

View file

@ -9,6 +9,7 @@ use crate::window;
use std::borrow::Cow;
#[derive(Debug)]
pub struct Backend {
text_pipeline: crate::text::Pipeline,

View file

@ -8,6 +8,7 @@ use crate::graphics::geometry::{self, Path, Style, Text};
use crate::graphics::Gradient;
use crate::primitive::{self, Primitive};
#[derive(Debug)]
pub struct Frame {
size: Size,
transform: tiny_skia::Transform,

View file

@ -1,5 +1,4 @@
#![forbid(rust_2018_idioms)]
#![deny(unsafe_code, unused_results, rustdoc::broken_intra_doc_links)]
#![allow(missing_docs)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod window;

View file

@ -6,6 +6,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
use std::cell::RefCell;
use std::collections::hash_map;
#[derive(Debug)]
pub struct Pipeline {
cache: RefCell<Cache>,
}
@ -68,7 +69,7 @@ impl Pipeline {
}
}
#[derive(Default)]
#[derive(Debug, Default)]
struct Cache {
entries: FxHashMap<u64, Option<Entry>>,
hits: FxHashSet<u64>,
@ -119,6 +120,7 @@ impl Cache {
}
}
#[derive(Debug)]
struct Entry {
width: u32,
height: u32,

View file

@ -13,7 +13,7 @@ use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::hash_map;
#[allow(missing_debug_implementations)]
#[derive(Debug)]
pub struct Pipeline {
glyph_cache: GlyphCache,
cache: RefCell<Cache>,

View file

@ -9,6 +9,7 @@ use std::cell::RefCell;
use std::collections::hash_map;
use std::fs;
#[derive(Debug)]
pub struct Pipeline {
cache: RefCell<Cache>,
}
@ -203,3 +204,13 @@ impl Cache {
self.raster_hits.clear();
}
}
impl std::fmt::Debug for Cache {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct("Cache")
.field("tree_hits", &self.tree_hits)
.field("rasters", &self.rasters)
.field("raster_hits", &self.raster_hits)
.finish_non_exhaustive()
}
}

View file

@ -8,11 +8,13 @@ use crate::{Backend, Primitive, Renderer, Settings};
use std::collections::VecDeque;
use std::num::NonZeroU32;
#[allow(missing_debug_implementations)]
pub struct Compositor {
context: softbuffer::Context<Box<dyn compositor::Window>>,
settings: Settings,
}
#[allow(missing_debug_implementations)]
pub struct Surface {
window: softbuffer::Surface<
Box<dyn compositor::Window>,

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true
@ -44,3 +47,4 @@ resvg.optional = true
tracing.workspace = true
tracing.optional = true

View file

@ -20,14 +20,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unsafe_code,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub mod layer;
pub mod primitive;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
all-features = true

View file

@ -2,13 +2,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(unsafe_code, rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use iced_renderer as renderer;
pub use iced_renderer::graphics;

View file

@ -10,6 +10,9 @@ homepage.workspace = true
categories.workspace = true
keywords.workspace = true
[lints]
workspace = true
[features]
default = ["x11", "wayland", "wayland-dlopen", "wayland-csd-adwaita"]
debug = ["iced_runtime/debug"]
@ -41,3 +44,4 @@ winapi.workspace = true
[target.'cfg(target_arch = "wasm32")'.dependencies]
web-sys.workspace = true
web-sys.features = ["Document", "Window"]

View file

@ -17,14 +17,6 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/iced-rs/iced/9ab6923e943f784985e9ef9ca28b10278297225d/docs/logo.svg"
)]
#![forbid(rust_2018_idioms)]
#![deny(
missing_debug_implementations,
missing_docs,
unused_results,
unsafe_code,
rustdoc::broken_intra_doc_links
)]
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
pub use iced_graphics as graphics;
pub use iced_runtime as runtime;