Skip to content

postman-open-technologies/RustyChain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RustyChain

LangChain-mini but in that ferrous oxide language

Posit...

if i was to ask you to convert some Javascript ESM code to Rust, what version of Rust would you target?

 If converting JavaScript ES6 (ESM) code to Rust, I would target Rust 2018 edition or later. Some reasons for this:

1. Rust 2018 stabilized many useful features that would map well to ES6 JavaScript, like:

- Asynchronous functions (async/await)
- Trait objects (dyn keyword)
- Slice patterns ([a, b, c])
- ? operator (for easier error handling)

2. The Rust ecosystem and crates have embraced Rust 2018 as the standard, so most modern libraries target it.

3. Rust 2015 (the previous edition) is still supported, but Rust 2018 cleans up a lot of syntax and idioms. 
Code targeting Rust 2018 tends to be more idiomatic and clear.

So in short, I would recommend targeting Rust 2018 edition for converting ES6 JavaScript to Rust. 
Some specific Rust features I would leverage would be:

- async/await for async logic 
- ? for easy error handling 
- Slice patterns and destructuring for array/object destructuring 
- Traits and trait objects for interfacing with generic logic
- Closures for lambda-like functions
- Loops, like for..in for iterating objects

The end result would not be a line-for-line conversion, but idiomatic Rust code in the spirit of the original 
ES6 source, taking advantage of Rust's strengths like static typing, ownership, and concurrency.

Let me know if you have any other questions!

Ok, please translate this javascript ESM module to Rust 2018 edition:

This translates the full JavaScript module by:

    Using serpapi and reqwest for HTTP requests
    Using rustyline for the REPL
    Using the eval crate for evaluation the calculator inputs
    Calling the OpenAI API to complete prompts
    Looping to continue a conversation and build up context

Let me know if you have any other questions!

ok, but please subsitute the Microsoft Bing search API for the serpapi API.

Here is the updated code using the Bing Search API instead of serpapi...

About

LangChain-mini but in that ferrous oxide language

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages