Repository: fschutt/printpdf (language: rust)

Issue:
Support stable Rust
Using `#![feature(try_from)]` makes this impossible to use from projects based on stable Rust.


Discussion / hints:
Oh, thanks! I used it for the image loading until #7 happened and removed all traces of `TryFrom` in https://github.com/fschutt/printpdf/commit/a834572d5c0cfb632cbf3da3d95033759ed7f704 - the feature isn't actually used. The library should work on stable, I just forgot to remove the `try_from`.

Thanks for reporting, I'll fix this!

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index d983cc6..9a9928a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,8 @@
 language: rust
 
 rust:
+  - stable
+  - beta
   - nightly
 
 sudo: false
diff --git a/README.md b/README.md
index e385663..e7ae274 100644
--- a/README.md
+++ b/README.md
@@ -121,13 +121,11 @@
  Scaling of images is implicitly done to fit one pixel = one dot at 300 dpi.
 
  ```
- #![feature(try_from)]
  extern crate printpdf;
  extern crate image; /* currently: version 0.14.0 */
 
  use printpdf::*;
  use std::fs::File;
- use std::convert::TryFrom;
  use std::convert::From;
 
  fn main() {
diff --git a/examples/images.rs b/examples/images.rs
index 11cbc8d..41b8396 100644
--- a/examples/images.rs
+++ b/examples/images.rs
@@ -1,10 +1,8 @@
-#![feature(try_from)]
 extern crate printpdf;
 extern crate image;
 
 use printpdf::*;
 use std::io::Cursor;
-use std::convert::TryFrom; 
 use image::bmp::BMPDecoder;
 use std::fs::File;
 
diff --git a/src/lib.rs b/src/lib.rs
index 6cbd8cd..7770e1f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -119,13 +119,11 @@
 //! Scaling of images is implicitly done to fit one pixel = one dot at 300 dpi.
 //!
 //! ```
-//! #![feature(try_from)]
 //! extern crate printpdf;
 //! extern crate image; /* currently: version 0.14.0 */
 //!
 //! use printpdf::*;
 //! use std::fs::File;
-//! use std::convert::TryFrom;
 //! use std::convert::From;
 //!
 //! fn main() {
@@ -321,8 +319,6 @@
 //! [PDF X/3 technical notes](http://www.pdfxreport.com/lib/exe/fetch.php?media=en:technote_pdfx_checks.pdf)
 //!
 
-#![feature(try_from)]
-
 #![allow(unused_doc_comment)]
 #![allow(unused_variables)]
 #![allow(dead_code)]
diff --git a/src/types/pdf_layer.rs b/src/types/pdf_layer.rs
index 716f10e..b309a5a 100644
--- a/src/types/pdf_layer.rs
+++ b/src/types/pdf_layer.rs
@@ -80,14 +80,13 @@ impl PdfLayerReference {
 
     /// Add an svg element to the layer
     /// To be called from the `svg.add_to_layer()` class (see `use_xobject` documentation)
-    pub(crate) fn add_svg<T>(&self, form: T)
-    -> std::result::Result<XObjectRef, T::Error>
-    where T: std::convert::TryInto<FormXObject>
+    pub(crate) fn add_svg(&self, svg: Svg)
+    -> std::result::Result<XObjectRef, ::std::io::Error>
     {
         let doc = self.document.upgrade().unwrap();
         let mut doc = doc.borrow_mut();
         let page_mut = &mut doc.pages[self.page.0];
-        let form_data = form.try_into()?;
+        let form_data = svg.try_into()?;
         Ok(page_mut.add_xobject(XObject::Form(Box::new(form_data))))
     }
 
diff --git a/src/types/plugins/graphics/two_dimensional/svg.rs b/src/types/plugins/graphics/two_dimensional/svg.rs
index 31395d3..fb28710 100644
--- a/src/types/plugins/graphics/two_dimensional/svg.rs
+++ b/src/types/plugins/graphics/two_dimensional/svg.rs
@@ -135,12 +135,8 @@ impl Svg {
 
         Ok(())
     }
-}
-
-impl std::convert::TryInto<FormXObject> for Svg {
-    type Error = std::io::Error;
 
-    fn try_into(self)
+    pub fn try_into(self)
     -> std::result::Result<FormXObject, std::io::Error>
     {
         let content = lopdf::content::Content{ operations: self.operations };


Test patch: