aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-semver/src/constraint/match_none_constraint.rs
blob: 587058a666848f6e0e5f23a1401f69a5a312f97a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! ref: composer/vendor/composer/semver/src/Constraint/MatchNoneConstraint.php

use crate::constraint::Bound;
use crate::constraint::ConstraintInterface;

#[derive(Debug)]
pub struct MatchNoneConstraint {
    pub(crate) pretty_string: Option<String>,
}

impl ConstraintInterface for MatchNoneConstraint {
    fn matches(&self, _provider: &dyn ConstraintInterface) -> bool {
        false
    }

    fn compile(&self, _other_operator: i64) -> String {
        "false".to_string()
    }

    fn set_pretty_string(&mut self, pretty_string: Option<String>) {
        self.pretty_string = pretty_string;
    }

    fn get_pretty_string(&self) -> String {
        if let Some(ref s) = self.pretty_string
            && !s.is_empty()
        {
            return s.clone();
        }
        self.__to_string()
    }

    fn __to_string(&self) -> String {
        "[]".to_string()
    }

    fn clone_box(&self) -> Box<dyn ConstraintInterface> {
        Box::new(MatchNoneConstraint {
            pretty_string: self.pretty_string.clone(),
        })
    }

    fn as_any(&self) -> &dyn std::any::Any {
        self
    }

    fn get_upper_bound(&self) -> Bound {
        Bound::new("0.0.0.0-dev".to_string(), false)
    }

    fn get_lower_bound(&self) -> Bound {
        Bound::new("0.0.0.0-dev".to_string(), false)
    }
}