impl page from
@@ -269,6 +269,25 @@ impl <T:Display+Debug>Display for Page<T>{
}
}
+impl<V> Page<V> {
+ pub fn from<T>(arg: Page<T>) -> Self where V: From<T> {
+ let mut p = Page::<V>::new(arg.page_no, arg.page_size);
+ p.pages = arg.pages;
+ p.page_no = arg.page_no;
+ p.page_size = arg.page_size;
+ p.total = arg.total;
+ p.search_count = arg.search_count;
+ p.records = {
+ let mut records = Vec::with_capacity(arg.records.len());
+ for x in arg.records {
+ records.push(V::from(x));
+ }
+ records
+ };
+ p
+ }
+}
+
#[cfg(test)]
mod test {
use crate::sql::page::Page;
