fn int_to_value(value: i32, field: &FieldDescriptor) -> Result<Value, &'static str>{
    match field.kind(){
        // Int
        Kind::Int32 | Kind::Sint32 => Ok(Value::I32(value)),
        // Month
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.month" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("months", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Date
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.date" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("days", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Minute
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.minute" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("minutes", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Second
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.second" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("seconds", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Time
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.time" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("millis", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // There are no other int compatible type
        _ => Err("non-int value\0")
    }
}
/// Convert underlying int value to `Value`.
Convert underlying int value to `Value`.
Convert underlying int value to ` Value ` .
fn int_to_value(value: i32, field: &FieldDescriptor) -> Result<Value, &'static str>{
    match field.kind(){
        // Int
        Kind::Int32 | Kind::Sint32 => Ok(Value::I32(value)),
        // Month
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.month" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("months", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Date
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.date" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("days", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Minute
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.minute" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("minutes", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Second
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.second" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("seconds", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // Time
        Kind::Message(message_descriptor) if message_descriptor.full_name() == "q.time" => {
            let mut inner = DynamicMessage::new(message_descriptor.clone());
            inner.set_field_by_name("millis", Value::I32(value));
            Ok(Value::Message(inner))
        },
        // There are no other int compatible type
        _ => Err("non-int value\0")
    }
}
fn int_to_value ( value : i32 , field : & FieldDescriptor ) -> Result < Value , & ' static str > { match field . kind ( ) { // Int Kind :: Int32 | Kind :: Sint32 => Ok ( Value :: I32 ( value ) ) , // Month Kind :: Message ( message_descriptor ) if message_descriptor . full_name ( ) == " " => { let mut inner = DynamicMessage :: new ( message_descriptor . clone ( ) ) ; inner . set_field_by_name ( " " , Value :: I32 ( value ) ) ; Ok ( Value :: Message ( inner ) ) } , // Date Kind :: Message ( message_descriptor ) if message_descriptor . full_name ( ) == " " => { let mut inner = DynamicMessage :: new ( message_descriptor . clone ( ) ) ; inner . set_field_by_name ( " " , Value :: I32 ( value ) ) ; Ok ( Value :: Message ( inner ) ) } , // Minute Kind :: Message ( message_descriptor ) if message_descriptor . full_name ( ) == " " => { let mut inner = DynamicMessage :: new ( message_descriptor . clone ( ) ) ; inner . set_field_by_name ( " " , Value :: I32 ( value ) ) ; Ok ( Value :: Message ( inner ) ) } , // Second Kind :: Message ( message_descriptor ) if message_descriptor . full_name ( ) == " " => { let mut inner = DynamicMessage :: new ( message_descriptor . clone ( ) ) ; inner . set_field_by_name ( " " , Value :: I32 ( value ) ) ; Ok ( Value :: Message ( inner ) ) } , // Time Kind :: Message ( message_descriptor ) if message_descriptor . full_name ( ) == " " => { let mut inner = DynamicMessage :: new ( message_descriptor . clone ( ) ) ; inner . set_field_by_name ( " " , Value :: I32 ( value ) ) ; Ok ( Value :: Message ( inner ) ) } , // There are no other int compatible type _ => Err ( " \0 " ) } }
Convert underlying int value to `Value`.
Convert underlying int value to ` Value ` .
value
i32
field
&FieldDescriptor
value
i32
field
&FieldDescriptor