Skip to content

Commit

Permalink
Make DataRequest.payload non-optional (#5037)
Browse files Browse the repository at this point in the history
Fixes #2956
  • Loading branch information
robertbastian authored Jun 11, 2024
1 parent 8a229de commit 90727cc
Show file tree
Hide file tree
Showing 589 changed files with 1,258 additions and 1,583 deletions.
2 changes: 1 addition & 1 deletion components/calendar/src/chinese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ impl Chinese {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self {
data: Some(provider.load(Default::default())?.take_payload()?),
data: Some(provider.load(Default::default())?.payload),
})
}

Expand Down
2 changes: 1 addition & 1 deletion components/calendar/src/dangi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ impl Dangi {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self {
data: Some(provider.load(Default::default())?.take_payload()?),
data: Some(provider.load(Default::default())?.payload),
})
}

Expand Down
4 changes: 2 additions & 2 deletions components/calendar/src/islamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ impl IslamicObservational {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self {
data: Some(provider.load(Default::default())?.take_payload()?),
data: Some(provider.load(Default::default())?.payload),
})
}

Expand Down Expand Up @@ -189,7 +189,7 @@ impl IslamicUmmAlQura {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self {
data: Some(provider.load(Default::default())?.take_payload()?),
data: Some(provider.load(Default::default())?.payload),
})
}

Expand Down
4 changes: 2 additions & 2 deletions components/calendar/src/japanese.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl Japanese {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self {
eras: provider.load(Default::default())?.take_payload()?,
eras: provider.load(Default::default())?.payload,
})
}

Expand Down Expand Up @@ -202,7 +202,7 @@ impl JapaneseExtended {
provider: &D,
) -> Result<Self, DataError> {
Ok(Self(Japanese {
eras: provider.load(Default::default())?.take_payload()?.cast(),
eras: provider.load(Default::default())?.payload.cast(),
}))
}

Expand Down
15 changes: 6 additions & 9 deletions components/calendar/src/week_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ impl WeekCalculator {
..Default::default()
},
)
.and_then(DataResponse::take_payload)
.map(|payload| payload.get().into())
.map(|response| response.payload.get().into())
.map_err(|_| e)
})
}
Expand All @@ -89,8 +88,7 @@ impl WeekCalculator {
..Default::default()
},
)
.and_then(DataResponse::take_payload)
.map(|payload| payload.get().into())
.map(|response| response.payload.get().into())
.map_err(|_| e)
})
}
Expand All @@ -105,11 +103,10 @@ impl WeekCalculator {
locale,
..Default::default()
})
.and_then(DataResponse::take_payload)
.map(|payload| WeekCalculator {
first_weekday: payload.get().first_weekday,
min_week_days: payload.get().min_week_days,
weekend: Some(payload.get().weekend),
.map(|response| WeekCalculator {
first_weekday: response.payload.get().first_weekday,
min_week_days: response.payload.get().min_week_days,
weekend: Some(response.payload.get().weekend),
})
.map_err(Into::into)
}
Expand Down
2 changes: 1 addition & 1 deletion components/casemap/src/casemapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl CaseMapper {
where
P: DataProvider<CaseMapV1Marker> + ?Sized,
{
let data = provider.load(Default::default())?.take_payload()?;
let data = provider.load(Default::default())?.payload;
Ok(Self { data })
}

Expand Down
4 changes: 2 additions & 2 deletions components/casemap/src/closer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl CaseMapCloser<CaseMapper> {
P: DataProvider<CaseMapV1Marker> + DataProvider<CaseMapUnfoldV1Marker> + ?Sized,
{
let cm = CaseMapper::try_new_unstable(provider)?;
let unfold = provider.load(Default::default())?.take_payload()?;
let unfold = provider.load(Default::default())?.payload;
Ok(Self { cm, unfold })
}
}
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<CM: AsRef<CaseMapper>> CaseMapCloser<CM> {
where
P: DataProvider<CaseMapV1Marker> + DataProvider<CaseMapUnfoldV1Marker> + ?Sized,
{
let unfold = provider.load(Default::default())?.take_payload()?;
let unfold = provider.load(Default::default())?.payload;
Ok(Self {
cm: casemapper,
unfold,
Expand Down
19 changes: 9 additions & 10 deletions components/collator/src/comparison.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,10 @@ impl Collator {
{
Self::try_new_unstable_internal(
provider,
provider.load(Default::default())?.take_payload()?,
provider.load(Default::default())?.take_payload()?,
provider.load(Default::default())?.take_payload()?,
|| provider.load(Default::default())?.take_payload(),
provider.load(Default::default())?.payload,
provider.load(Default::default())?.payload,
provider.load(Default::default())?.payload,
|| provider.load(Default::default()).map(|r| r.payload),
locale,
options,
)
Expand Down Expand Up @@ -149,20 +149,20 @@ impl Collator {
};

let metadata_payload: DataPayload<crate::provider::CollationMetadataV1Marker> =
provider.load(req)?.take_payload()?;
provider.load(req)?.payload;

let metadata = metadata_payload.get();

let tailoring: Option<DataPayload<crate::provider::CollationDataV1Marker>> =
if metadata.tailored() {
Some(provider.load(req)?.take_payload()?)
Some(provider.load(req)?.payload)
} else {
None
};

let reordering: Option<DataPayload<crate::provider::CollationReorderingV1Marker>> =
if metadata.reordering() {
Some(provider.load(req)?.take_payload()?)
Some(provider.load(req)?.payload)
} else {
None
};
Expand All @@ -175,8 +175,7 @@ impl Collator {
}
}

let root: DataPayload<CollationDataV1Marker> =
provider.load(Default::default())?.take_payload()?;
let root: DataPayload<CollationDataV1Marker> = provider.load(Default::default())?.payload;

let tailored_diacritics = metadata.tailored_diacritics();
let diacritics: DataPayload<CollationDiacriticsV1Marker> = provider
Expand All @@ -185,7 +184,7 @@ impl Collator {
} else {
Default::default()
})?
.take_payload()?;
.payload;

if tailored_diacritics {
// In the tailored case we accept a shorter table in which case the tailoring is
Expand Down
Loading

0 comments on commit 90727cc

Please sign in to comment.