Skip to content

Commit d37df07

Browse files
committed
Remove lifetime from FluentBundle
1 parent 91bb69e commit d37df07

File tree

5 files changed

+16
-17
lines changed

5 files changed

+16
-17
lines changed

fluent-bundle/src/bundle.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,15 @@ pub struct Message<'m> {
8484
/// [`compound`]: ./struct.FluentBundle.html#method.compound
8585
/// [`add_resource`]: ./struct.FluentBundle.html#method.add_resource
8686
/// [`Option<T>`]: http://doc.rust-lang.org/std/option/enum.Option.html
87-
pub struct FluentBundle<'bundle, R> {
87+
pub struct FluentBundle<R> {
8888
pub locales: Vec<String>,
8989
pub(crate) resources: Vec<R>,
90-
pub(crate) entries: HashMap<String, Entry<'bundle>>,
90+
pub(crate) entries: HashMap<String, Entry>,
9191
pub(crate) plural_rules: IntlPluralRules,
9292
pub(crate) use_isolating: bool,
9393
}
9494

95-
impl<'bundle, R> FluentBundle<'bundle, R> {
95+
impl<R> FluentBundle<R> {
9696
/// Constructs a FluentBundle. `locales` is the fallback chain of locales
9797
/// to use for formatters like date and time. `locales` does not influence
9898
/// message selection.
@@ -277,7 +277,7 @@ impl<'bundle, R> FluentBundle<'bundle, R> {
277277
/// ```
278278
///
279279
/// [FTL syntax guide]: https://projectfluent.org/fluent/guide/functions.html
280-
pub fn add_function<F: 'bundle>(&mut self, id: &str, func: F) -> Result<(), FluentError>
280+
pub fn add_function<F: 'static>(&mut self, id: &str, func: F) -> Result<(), FluentError>
281281
where
282282
F: for<'a> Fn(&[FluentValue<'a>], &HashMap<&str, FluentValue<'a>>) -> FluentValue<'a>
283283
+ Sync
@@ -372,7 +372,7 @@ impl<'bundle, R> FluentBundle<'bundle, R> {
372372
/// .expect("Failed to format a message.");
373373
/// assert_eq!(&value, "a foo b");
374374
/// ```
375-
pub fn format(
375+
pub fn format<'bundle>(
376376
&'bundle self,
377377
path: &str,
378378
args: Option<&'bundle HashMap<&str, FluentValue>>,
@@ -452,7 +452,7 @@ impl<'bundle, R> FluentBundle<'bundle, R> {
452452
/// The second term of the tuple will contain any extra error information
453453
/// gathered during formatting. A caller may safely ignore the extra errors
454454
/// if the fallback formatting policies are acceptable.
455-
pub fn compound(
455+
pub fn compound<'bundle>(
456456
&'bundle self,
457457
message_id: &str,
458458
args: Option<&'bundle HashMap<&str, FluentValue>>,

fluent-bundle/src/entry.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,16 @@ use crate::bundle::FluentBundle;
99
use crate::resource::FluentResource;
1010
use crate::types::FluentValue;
1111

12-
pub type FluentFunction<'bundle> = Box<
13-
dyn 'bundle
14-
+ for<'a> Fn(&[FluentValue<'a>], &HashMap<&str, FluentValue<'a>>) -> FluentValue<'a>
12+
pub type FluentFunction = Box<
13+
dyn for<'a> Fn(&[FluentValue<'a>], &HashMap<&str, FluentValue<'a>>) -> FluentValue<'a>
1514
+ Send
1615
+ Sync,
1716
>;
1817

19-
pub enum Entry<'bundle> {
18+
pub enum Entry {
2019
Message([usize; 2]),
2120
Term([usize; 2]),
22-
Function(FluentFunction<'bundle>),
21+
Function(FluentFunction),
2322
}
2423

2524
pub trait GetEntry {
@@ -28,7 +27,7 @@ pub trait GetEntry {
2827
fn get_function(&self, id: &str) -> Option<&FluentFunction>;
2928
}
3029

31-
impl<'bundle, R: Borrow<FluentResource>> GetEntry for FluentBundle<'_, R> {
30+
impl<'bundle, R: Borrow<FluentResource>> GetEntry for FluentBundle<R> {
3231
fn get_message(&self, id: &str) -> Option<&ast::Message> {
3332
self.entries.get(id).and_then(|entry| match *entry {
3433
Entry::Message(pos) => {

fluent-bundle/src/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub enum ResolverError {
3434
/// State for a single `ResolveValue::to_value` call.
3535
pub struct Scope<'bundle, R: Borrow<FluentResource>> {
3636
/// The current `FluentBundle` instance.
37-
pub bundle: &'bundle FluentBundle<'bundle, R>,
37+
pub bundle: &'bundle FluentBundle<R>,
3838
/// The current arguments passed by the developer.
3939
pub args: Option<&'bundle HashMap<&'bundle str, FluentValue<'bundle>>>,
4040
/// Local args

fluent-fallback/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ use fluent_bundle::FluentValue;
88
use reiterate::Reiterate;
99

1010
struct FluentBundleIterator<'loc, R> {
11-
iter: Box<dyn Iterator<Item = FluentBundle<'loc, R>> + 'loc>,
11+
iter: Box<dyn Iterator<Item = FluentBundle<R>> + 'loc>,
1212
}
1313

1414
impl<'loc, R> Iterator for FluentBundleIterator<'loc, R> {
15-
type Item = Box<FluentBundle<'loc, R>>;
15+
type Item = Box<FluentBundle<R>>;
1616
fn next(&mut self) -> Option<Self::Item> {
1717
self.iter.next().map(Box::new)
1818
}
@@ -28,7 +28,7 @@ impl<'loc, R> Localization<'loc, R> {
2828
pub fn new<F, I>(resource_ids: Vec<String>, mut generate_bundles: F) -> Self
2929
where
3030
F: FnMut(&[String]) -> I + 'loc,
31-
I: Iterator<Item = FluentBundle<'loc, R>> + 'loc,
31+
I: Iterator<Item = FluentBundle<R>> + 'loc,
3232
{
3333
let mut generate2 = move |x: &[String]| FluentBundleIterator {
3434
iter: Box::new(generate_bundles(x)),

fluent-resmgr/src/resource_manager.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl ResourceManager {
5555
&'l self,
5656
locales: Vec<String>,
5757
resource_ids: Vec<String>,
58-
) -> impl Iterator<Item = FluentBundle<'l, &FluentResource>> {
58+
) -> impl Iterator<Item = FluentBundle<&FluentResource>> {
5959
let res_mgr = self;
6060
let mut ptr = 0;
6161

0 commit comments

Comments
 (0)