Skip to content

Commit 1254911

Browse files
committed
Review
1 parent 985d359 commit 1254911

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

src/errors/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn ceil_char_boundary(value: &str, index: usize) -> usize {
6464
.map_or(upper_bound, |pos| pos + index)
6565
}
6666

67-
pub fn truncate_large_string<F: fmt::Write>(f: &mut F, val: Cow<'_, str>) -> std::fmt::Result {
67+
pub fn write_truncated_to_50_bytes<F: fmt::Write>(f: &mut F, val: Cow<'_, str>) -> std::fmt::Result {
6868
if val.len() > 50 {
6969
write!(
7070
f,

src/errors/validation_exception.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ impl PyLineError {
526526
let input_value = self.input_value.bind(py);
527527
let input_str = safe_repr(input_value);
528528
write!(output, ", input_value=")?;
529-
super::truncate_large_string(&mut output, input_str.to_cow())?;
529+
super::write_truncated_to_50_bytes(&mut output, input_str.to_cow())?;
530530

531531
if let Ok(type_) = input_value.get_type().qualname() {
532532
write!(output, ", input_type={type_}")?;

src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,10 @@ use validators::ValBytesMode;
1414
#[macro_use]
1515
mod py_gc;
1616

17-
pub mod errors;
18-
1917
mod argument_markers;
2018
mod build_tools;
2119
mod definitions;
20+
mod errors;
2221
mod input;
2322
mod lookup_key;
2423
mod recursion_guard;

src/serializers/extra.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -429,15 +429,12 @@ impl CollectWarnings {
429429
let input_str = safe_repr(value);
430430
let mut value_str = String::with_capacity(100);
431431
value_str.push_str("with value `");
432-
match crate::errors::truncate_large_string(&mut value_str, input_str.to_cow()) {
433-
Err(_) => value_str.clear(),
434-
Ok(()) => {
435-
value_str.push_str("` ");
436-
}
437-
};
432+
crate::errors::write_truncated_to_50_bytes(&mut value_str, input_str.to_cow())
433+
.expect("Writing to a `String` failed");
434+
value_str.push_str("`");
438435

439436
self.add_warning(format!(
440-
"Expected `{field_type}` but got `{type_name}` {value_str}- serialized value may not be as expected"
437+
"Expected `{field_type}` but got `{type_name}` {value_str} - serialized value may not be as expected"
441438
));
442439
}
443440
}

0 commit comments

Comments
 (0)