Repository: J-F-Liu/lopdf (language: rust)

Issue:
Remove `Object::as_string`
I would like to get your opinion on this @brmmm3: I'd like to remove `Object::as_string`, because I think it provides a misleading interface to convert an object, as basically no object in PDFs is encoded in UTF-8.

A few days ago, I implemented #297, which is able to properly decode a text string, no matter if it's encoded in UTF-8, UTF-16BE or PDFDocEncoding.


Discussion / hints:

Fix patch:
diff --git a/src/object.rs b/src/object.rs
index e8ff0a3..3137a55 100644
--- a/src/object.rs
+++ b/src/object.rs
@@ -196,13 +196,6 @@ impl Object {
         }
     }
 
-    pub fn as_string(&self) -> Result<std::borrow::Cow<'_, str>> {
-        match self {
-            Object::String(string, _) => Ok(std::string::String::from_utf8_lossy(string)),
-            _ => Err(Error::Type),
-        }
-    }
-
     pub fn as_reference(&self) -> Result<ObjectId> {
         match *self {
             Object::Reference(ref id) => Ok(*id),


Test patch: