[librsvg: 5/15] derive(Default) for Path
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 5/15] derive(Default) for Path
- Date: Tue, 1 Dec 2020 22:17:53 +0000 (UTC)
commit 0910b3ecccdcda13446f5a9585a064e581bae1ea
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Dec 1 14:31:22 2020 -0600
derive(Default) for Path
This struct has two boxed slices, and we actually want the default to be
slices with zero elements - so this matches the Default for Box<[T; 0]>
src/path_builder.rs | 10 ++++++++++
1 file changed, 10 insertions(+)
---
diff --git a/src/path_builder.rs b/src/path_builder.rs
index 5d87dad7..5377d8c5 100644
--- a/src/path_builder.rs
+++ b/src/path_builder.rs
@@ -453,6 +453,9 @@ pub struct PathBuilder {
///
/// Each `PathCommand` knows how many coordinates it ought to produce, with
/// its `num_coordinates` method.
+///
+/// This struct implements `Default`, and it yields an empty path.
+#[derive(Default)]
pub struct Path {
commands: Box<[PackedCommand]>,
coords: Box<[f64]>,
@@ -708,6 +711,13 @@ mod tests {
assert_eq!(path.iter().count(), 0);
}
+ #[test]
+ fn empty_path() {
+ let path = Path::default();
+ assert!(path.is_empty());
+ assert_eq!(path.iter().count(), 0);
+ }
+
#[test]
fn all_commands() {
let mut builder = PathBuilder::default();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]