Kriskras99 commented on code in PR #429:
URL: https://github.com/apache/avro-rs/pull/429#discussion_r2721549747
##########
avro/src/schema/record/schema.rs:
##########
@@ -42,6 +45,18 @@ pub struct RecordSchema {
pub attributes: BTreeMap<String, Value>,
}
+use record_schema_builder::{IsUnset, SetName, State};
Review Comment:
Let's move these to the top of the file, or replace the import by full paths
in the `impl`
##########
avro/src/schema/record/schema.rs:
##########
@@ -42,6 +45,18 @@ pub struct RecordSchema {
pub attributes: BTreeMap<String, Value>,
}
+use record_schema_builder::{IsUnset, SetName, State};
+impl<S: State> RecordSchemaBuilder<S> {
+ /// Try to set a Name from the given string.
+ pub fn try_name(self, name: impl Into<String>) ->
AvroResult<RecordSchemaBuilder<SetName<S>>>
+ where
+ <S as State>::Name: IsUnset,
+ {
+ let name = Name::try_from(name.into())?;
+ Ok(self.name(name))
Review Comment:
```suggestion
pub fn try_name<T>(self, name: T) ->
Result<RecordSchemaBuilder<SetName<S>>, <T as TryInto<Name>>::Error>
where
<S as State>::Name: IsUnset,
T: TryInto<Name>,
{
let name = name.try_into()?;
Ok(self.name(name))
```
This makes the function more generic and allows users to convert from their
own types.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]