• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

extphprs / ext-php-rs / 21003181884

14 Jan 2026 05:14PM UTC coverage: 35.776% (-0.02%) from 35.791%
21003181884

Pull #643

github

web-flow
Merge 0037edc47 into 25f53632f
Pull Request #643: feat(string): smartstring support

0 of 2 new or added lines in 1 file covered. (0.0%)

1811 of 5062 relevant lines covered (35.78%)

13.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/types/string/smartstring_impl.rs
1
use super::{DataType, FromZval, IntoZval, Result, Zval};
2
use smartstring::{LazyCompact, SmartString};
3

4
impl<M: smartstring::SmartStringMode> IntoZval for SmartString<M> {
5
    const TYPE: DataType = DataType::String;
6
    const NULLABLE: bool = false;
7

NEW
8
    fn set_zval(self, zv: &mut Zval, persistent: bool) -> Result<()> {
×
NEW
9
        zv.set_string(self.as_str(), persistent)
×
10
    }
11
}
12

13
impl FromZval<'_> for SmartString<LazyCompact> {
14
    const TYPE: DataType = DataType::String;
15

16
    fn from_zval(zval: &Zval) -> Option<Self> {
17
        zval.str().map(SmartString::from)
18
    }
19
}
20

21
#[cfg(test)]
22
#[cfg(feature = "embed")]
23
mod tests {
24
    use super::*;
25
    use crate::convert::FromZval;
26
    use crate::embed::Embed;
27

28
    #[test]
29
    fn test_smartstring_from_zval() {
30
        Embed::run(|| {
31
            let result = Embed::eval("'hello smartstring';");
32
            assert!(result.is_ok());
33

34
            let zval = result.as_ref().unwrap();
35
            let smart: Option<SmartString<LazyCompact>> = FromZval::from_zval(zval);
36
            assert_eq!(smart, Some(SmartString::from("hello smartstring")));
37
        });
38
    }
39

40
    #[test]
41
    fn test_smartstring_into_zval() {
42
        Embed::run(|| {
43
            let smart: SmartString<LazyCompact> = SmartString::from("test string");
44
            let zval = smart.into_zval(false).unwrap();
45

46
            assert!(zval.is_string());
47
            assert_eq!(zval.str(), Some("test string"));
48
        });
49
    }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc