diff --git a/examples/word-count-cls/README.md b/examples/word-count-cls/README.md index 0a38437f..d0c077bf 100644 --- a/examples/word-count-cls/README.md +++ b/examples/word-count-cls/README.md @@ -11,5 +11,5 @@ python setup.py install ```python from word_count_cls import WordCounter -WordCounter().search('path/to/file', 'word') -``` +WordCounter('path/to/file').search('word') +``` \ No newline at end of file diff --git a/examples/word-count-cls/src/lib.rs b/examples/word-count-cls/src/lib.rs index 6e2f463e..05eb33bc 100644 --- a/examples/word-count-cls/src/lib.rs +++ b/examples/word-count-cls/src/lib.rs @@ -13,17 +13,17 @@ use rayon::prelude::*; use pyo3::prelude::*; #[py::class] -struct Words { +struct WordCounter { path: String, token: PyToken, } #[py::methods] -impl Words { +impl WordCounter { #[new] fn __new__(obj: &PyRawObject, path: String) -> PyResult<()> { - obj.init(|t| Words {path: path, token: t}) + obj.init(|t| WordCounter {path: path, token: t}) } fn search(&self, py: Python, search: String) -> PyResult { @@ -85,7 +85,7 @@ fn wc_parallel(lines: &str, search: &str) -> i32 { #[py::modinit(_word_count)] fn init_mod(_py: Python, m: &PyModule) -> PyResult<()> { - m.add_class::()?; + m.add_class::()?; Ok(()) } diff --git a/examples/word-count-cls/tests/test_word_count.py b/examples/word-count-cls/tests/test_word_count.py index e582d2dd..cdd9413d 100644 --- a/examples/word-count-cls/tests/test_word_count.py +++ b/examples/word-count-cls/tests/test_word_count.py @@ -41,12 +41,12 @@ Namespaces are one honking great idea -- let's do more of those!\n''' * 1000 def test_word_count_rust_parallel(benchmark): - count = benchmark(word_count_cls.Words(path).search, 'is') + count = benchmark(word_count_cls.WordCounter(path).search, 'is') assert count == 10000 def test_word_count_rust_sequential(benchmark): - count = benchmark(word_count_cls.Words(path).search_sequential, 'is') + count = benchmark(word_count_cls.WordCounter(path).search_sequential, 'is') assert count == 10000 diff --git a/examples/word-count-cls/word_count_cls/__init__.py b/examples/word-count-cls/word_count_cls/__init__.py index eab0efd4..e9abc928 100644 --- a/examples/word-count-cls/word_count_cls/__init__.py +++ b/examples/word-count-cls/word_count_cls/__init__.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import absolute_import -from ._word_count import Words +from ._word_count import WordCounter -__all__ = ['Words', 'search_py'] +__all__ = ['WordCounter', 'search_py'] def search_py(path, needle):