[librsvg/rustification] path_builder.rs: Make RsvgPathBuilder's methods public



commit a9fde1fe351997205c8f4ae377174ccc6e7a378a
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Nov 1 18:50:31 2016 -0600

    path_builder.rs: Make RsvgPathBuilder's methods public
    
    Also, fix .get_path_segments(): it does not need a &mut self; it can
    do with a &self since it only lends out the path_segments.

 rust/src/path_builder.rs |   24 +++++++++++++++---------
 1 files changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/rust/src/path_builder.rs b/rust/src/path_builder.rs
index 43eadfb..1323f09 100644
--- a/rust/src/path_builder.rs
+++ b/rust/src/path_builder.rs
@@ -8,20 +8,29 @@ pub struct RsvgPathBuilder {
 }
 
 impl RsvgPathBuilder {
-    fn move_to (&mut self, x: f64, y: f64) {
+    pub fn new () -> RsvgPathBuilder {
+        let builder = RsvgPathBuilder {
+            path_segments: Vec::new (),
+            last_move_to_index: None
+        };
+
+        builder
+    }
+
+    pub fn move_to (&mut self, x: f64, y: f64) {
         self.path_segments.push (cairo::PathSegment::MoveTo ((x, y)));
         self.last_move_to_index = Some (self.path_segments.len () - 1);
     }
 
-    fn line_to (&mut self, x: f64, y: f64) {
+    pub fn line_to (&mut self, x: f64, y: f64) {
         self.path_segments.push (cairo::PathSegment::LineTo ((x, y)));
     }
 
-    fn curve_to (&mut self, x2: f64, y2: f64, x3: f64, y3: f64, x4: f64, y4: f64) {
+    pub fn curve_to (&mut self, x2: f64, y2: f64, x3: f64, y3: f64, x4: f64, y4: f64) {
         self.path_segments.push (cairo::PathSegment::CurveTo ((x2, y2), (x3, y3), (x4, y4)));
     }
 
-    fn close_path (&mut self) {
+    pub fn close_path (&mut self) {
         if let Some (idx) = self.last_move_to_index {
             let segment = self.path_segments[idx];
 
@@ -33,17 +42,14 @@ impl RsvgPathBuilder {
         }
     }
 
-    fn get_path_segments (&mut self) -> &Vec<cairo::PathSegment> {
+    pub fn get_path_segments (&self) -> &Vec<cairo::PathSegment> {
         &self.path_segments
     }
 }
 
 #[no_mangle]
 pub unsafe extern fn rsvg_path_builder_new () -> *mut RsvgPathBuilder {
-    let builder = RsvgPathBuilder {
-        path_segments: Vec::new (),
-        last_move_to_index: None
-    };
+    let builder = RsvgPathBuilder::new ();
 
     let boxed_builder = Box::new (builder);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]