Skip to content

Commit

Permalink
fix: require functions in paginators to be thread-safe (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebRollen authored Nov 16, 2021
1 parent 4307a26 commit a518534
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ pub mod query {

/// A paginator that implements pagination through one or more query parameters.
pub struct QueryPaginator<T, U> {
f: Box<dyn Fn(Option<&U>, &T) -> Option<U>>,
f: Box<dyn 'static + Send + Sync + Fn(Option<&U>, &T) -> Option<U>>,
_phantom: std::marker::PhantomData<T>,
}

impl<T, U> QueryPaginator<T, U> {
pub fn new<F: 'static + Fn(Option<&U>, &T) -> Option<U>>(f: F) -> Self {
pub fn new<F: 'static + Send + Sync + Fn(Option<&U>, &T) -> Option<U>>(f: F) -> Self {
Self {
f: Box::new(f),
_phantom: std::marker::PhantomData,
Expand Down Expand Up @@ -166,12 +166,12 @@ pub mod path {
/// the paginator should return the path segment number and the new path segment, e.g. (2, "foo")
/// represents changing the third path segment to "foo"
pub struct PathPaginator<T, U> {
f: Box<dyn Fn(Option<&U>, &T) -> Option<U>>,
f: Box<dyn 'static + Send + Sync + Fn(Option<&U>, &T) -> Option<U>>,
_phantom: std::marker::PhantomData<T>,
}

impl<T, U> PathPaginator<T, U> {
pub fn new<F: 'static + Fn(Option<&U>, &T) -> Option<U>>(f: F) -> Self {
pub fn new<F: 'static + Send + Sync + Fn(Option<&U>, &T) -> Option<U>>(f: F) -> Self {
Self {
f: Box::new(f),
_phantom: std::marker::PhantomData,
Expand Down

0 comments on commit a518534

Please sign in to comment.