nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: ron-rs/ron
Pull request #56 (2017-10-04 16:39:59)

Fix bugs
Turns out I actually used this pattern 3 times..

Xaeroxe: Ping @kvark

It'd be really nice to get this big fix released as a patch version.

Patch:
diff --git a/Cargo.toml b/Cargo.toml
index 954a4bca..f76f9b47 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "ron"
-version = "0.1.1"
+version = "0.1.2"
 license = "MIT/Apache-2.0"
 keywords = ["parser", "serde", "serialization"]
 authors = [
diff --git a/src/de/error.rs b/src/de/error.rs
index 9ee028df..7cf9f028 100644
--- a/src/de/error.rs
+++ b/src/de/error.rs
@@ -39,6 +39,7 @@ pub enum ParseError {
     ExpectedUnit,
     ExpectedStructName,
     ExpectedString,
+    ExpectedStringEnd,
     ExpectedIdentifier,
 
     InvalidEscape,
diff --git a/src/parse.rs b/src/parse.rs
index 0f2596d5..b5bb9bf8 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -177,8 +177,8 @@ impl<'a> Bytes<'a> {
     }
 
     pub fn next_bytes_contained_in(&self, allowed: &[u8]) -> usize {
-        (0..self.bytes.len())
-            .flat_map(|i| self.bytes.get(i))
+        self.bytes
+            .iter()
             .take_while(|b| allowed.contains(b))
             .fold(0, |acc, _| acc + 1)
     }
@@ -224,11 +224,11 @@ impl<'a> Bytes<'a> {
             return self.err(ParseError::ExpectedString);
         }
 
-        let (i, end_or_escape) = (0..)
-            .flat_map(|i| self.bytes.get(i))
+        let (i, end_or_escape) = self.bytes
+            .iter()
             .enumerate()
             .find(|&(_, &b)| b == b'\\' || b == b'"')
-            .ok_or(self.error(ParseError::Eof))?;
+            .ok_or(self.error(ParseError::ExpectedStringEnd))?;
 
         if *end_or_escape == b'"' {
             let s = from_utf8(&self.bytes[..i]).map_err(|e| self.error(e.into()))?;
@@ -246,8 +246,8 @@ impl<'a> Bytes<'a> {
                 let _ = self.advance(i + 1);
                 self.parse_str_escape(&mut s)?;
 
-                let (new_i, end_or_escape) = (0..)
-                    .flat_map(|i| self.bytes.get(i))
+                let (new_i, end_or_escape) = self.bytes
+                    .iter()
                     .enumerate()
                     .find(|&(_, &b)| b == b'\\' || b == b'"')
                     .ok_or(ParseError::Eof)


Test patch:
diff --git a/src/de/tests.rs b/src/de/tests.rs
index 65d15bb7..887d7e24 100644
--- a/src/de/tests.rs
+++ b/src/de/tests.rs
@@ -159,3 +159,13 @@ fn untagged() {
 
     assert_eq!(from_str::<Untagged>("true").unwrap(), Untagged::Bool(true));
 }
+
+#[test]
+fn forgot_apostrophes() {
+    let de: Result<(i32, String)> = from_str("(4, \"Hello)");
+
+    assert!(match de {
+        Err(Error::Parser(ParseError::ExpectedStringEnd, _)) => true,
+        _ => false,
+    });
+}
Repository: ron-rs/ron
Pull request #148 (2019-02-28 22:13:05)

Add integer check for deserializer
Fix a problem with untagged enum deserialization


Patch:
diff --git a/src/de/mod.rs b/src/de/mod.rs
index 1a347370..930e6133 100644
--- a/src/de/mod.rs
+++ b/src/de/mod.rs
@@ -152,7 +152,14 @@ impl<'de, 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
             b'(' => self.handle_any_struct(visitor),
             b'[' => self.deserialize_seq(visitor),
             b'{' => self.deserialize_map(visitor),
-            b'0'...b'9' | b'+' | b'-' | b'.' => self.deserialize_f64(visitor),
+            b'0'...b'9' | b'+' | b'-' => {
+                if self.bytes.next_bytes_is_float() {
+                    self.deserialize_f64(visitor)
+                } else {
+                    self.deserialize_i64(visitor)
+                }
+            }
+            b'.' => self.deserialize_f64(visitor),
             b'"' | b'r' => self.deserialize_string(visitor),
             b'\'' => self.deserialize_char(visitor),
             other => self.bytes.err(ParseError::UnexpectedByte(other as char)),
diff --git a/src/parse.rs b/src/parse.rs
index e1358e35..4eaf4a80 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -324,6 +324,28 @@ impl<'a> Bytes<'a> {
             .fold(0, |acc, _| acc + 1)
     }
 
+    pub fn next_bytes_is_float(&self) -> bool {
+        if let Some(byte) = self.peek() {
+            let skip = match byte {
+                b'+' | b'-' => 1,
+                _ => 0,
+            };
+            let flen = self.bytes
+                        .iter()
+                        .skip(skip)
+                        .take_while(|b| FLOAT_CHARS.contains(b))
+                        .count();
+            let ilen = self.bytes
+                        .iter()
+                        .skip(skip)
+                        .take_while(|b| DIGITS.contains(b))
+                        .count();
+            flen > ilen
+        } else {
+            false
+        }
+    }
+
     pub fn skip_ws(&mut self) -> Result<()> {
         while self.peek()
             .map(|c| WHITE_SPACE.contains(&c))


Test patch:
diff --git a/src/de/tests.rs b/src/de/tests.rs
index 256142cf..45592fd9 100644
--- a/src/de/tests.rs
+++ b/src/de/tests.rs
@@ -197,6 +197,7 @@ fn untagged() {
     }
 
     assert_eq!(from_str::<Untagged>("true").unwrap(), Untagged::Bool(true));
+    assert_eq!(from_str::<Untagged>("8").unwrap(), Untagged::U8(8));
 }
 
 #[test]