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

extphprs / ext-php-rs / 21201972982

21 Jan 2026 08:09AM UTC coverage: 35.762% (-0.03%) from 35.791%
21201972982

push

github

web-flow
feat(string): smartstring support (#643)

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

1811 of 5064 relevant lines covered (35.76%)

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::{SmartString, SmartStringMode};
3

4
impl<M: 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<M: SmartStringMode> FromZval<'_> for SmartString<M> {
14
    const TYPE: DataType = DataType::String;
NEW
15
    fn from_zval(zval: &Zval) -> Option<Self> {
×
NEW
16
        zval.str().map(SmartString::from)
×
17
    }
18
}
19

20
#[cfg(test)]
21
#[cfg(feature = "embed")]
22
mod tests {
23
    use super::*;
24
    use crate::convert::FromZval;
25
    use crate::embed::Embed;
26
    use smartstring::LazyCompact;
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().expect("evaluation failed");
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).expect("evaluation failed");
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