text
stringlengths
232
16.3k
domain
stringclasses
1 value
difficulty
stringclasses
3 values
meta
dict
<|fim_prefix|>// repo: nndii/readlater-temporary path: /src/browser.rs use stdweb::js; use stdweb::unstable::TryInto; use stdweb::Reference; use crate::sync_storage::SyncStorage; use crate::tab::Tab; <|fim_suffix|> console.log("ACTIVE_TABS", @{self}.tabs); const active_tabs = @{self}.tabs.quer...
code_fim
hard
{ "lang": "rust", "repo": "nndii/readlater-temporary", "path": "/src/browser.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let memory: Vec<u32> = { // use same input from previous puzzle let file = File::open("input/day2_1").expect("Could not open file"); let mut reader = BufReader::new(file); let mut buf = String::new(); reader.read_line(&mut buf).expect("Could not read line"); ...
code_fim
medium
{ "lang": "rust", "repo": "robert-w-gries/advent_of_code", "path": "/2019/examples/day2_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let mut buf = String::new(); reader.read_line(&mut buf).expect("Could not read line"); buf.trim().split(',').map(|s| s.parse().unwrap()).collect() }; for noun in 0..100 { for verb in 0..100 { if intcode_execute(memory.clone(), noun, verb) { ...
code_fim
hard
{ "lang": "rust", "repo": "robert-w-gries/advent_of_code", "path": "/2019/examples/day2_2.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: robert-w-gries/advent_of_code path: /2019/examples/day2_2.rs use std::fs::File; use std::io::{prelude::*, BufReader}; fn intcode_execute(mut memory: Vec<u32>, noun: u32, verb: u32) -> bool { memory[1] = noun; memory[2] = verb; for i in (0..memory.len()).step_by(4) { match me...
code_fim
medium
{ "lang": "rust", "repo": "robert-w-gries/advent_of_code", "path": "/2019/examples/day2_2.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> /// Helper function to deserialize the inner RON string into `T`. pub fn into_rust<'de, T: Deserialize<'de>>(&'de self) -> SpannedResult<T> { Options::default().from_str(&self.ron) } /// Helper function to serialize `value` into a RON string. pub fn from_rust<T: Serialize>(val...
code_fim
hard
{ "lang": "rust", "repo": "ron-rs/ron", "path": "/src/value/raw.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ron-rs/ron path: /src/value/raw.rs // Inspired by David Tolnay's serde-rs // https://github.com/serde-rs/json/blob/master/src/raw.rs // Licensed under either of Apache License, Version 2.0 or MIT license at your option. use std::fmt; use serde::{de, ser, Deserialize, Serialize}; use crate::{ ...
code_fim
hard
{ "lang": "rust", "repo": "ron-rs/ron", "path": "/src/value/raw.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>impl<'de> Deserialize<'de> for Box<RawValue> { fn deserialize<D: de::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> { struct BoxedVisitor; impl<'de> de::Visitor<'de> for BoxedVisitor { type Value = Box<RawValue>; fn expecting(&self, formatter: &...
code_fim
hard
{ "lang": "rust", "repo": "ron-rs/ron", "path": "/src/value/raw.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rome/tools path: /crates/rome_js_formatter/src/js/bogus/bogus_expression.rs use crate::parentheses::NeedsParentheses; use crate::FormatBogusNodeRule; use rome_js_syntax::{JsBogusExpression, JsSyntaxNode}; <|fim_suffix|>impl NeedsParentheses for JsBogusExpression { #[inline] fn needs_par...
code_fim
medium
{ "lang": "rust", "repo": "rome/tools", "path": "/crates/rome_js_formatter/src/js/bogus/bogus_expression.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> while console.detect_infinite_cycle() { console.swap_next(); }; console.acc } } #[cfg(test)] mod tests { use crate::puzzles::day_08::*; #[test] fn test_part_one() { // given let _input = vec![ "nop +0", "acc +1"...
code_fim
hard
{ "lang": "rust", "repo": "szopqa/AOC_2020", "path": "/src/puzzles/day_08/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: szopqa/AOC_2020 path: /src/puzzles/day_08/mod.rs use crate::puzzles::solution::Solution; #[derive(Debug, Copy, Clone)] enum Instruction { NOP(i32), ACC(i32), JMP(i32) } impl Instruction { fn is_nop_or_jmp(&self) -> bool { match *self { Instruction::JMP(_) | ...
code_fim
hard
{ "lang": "rust", "repo": "szopqa/AOC_2020", "path": "/src/puzzles/day_08/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[test] fn test_parse_html() { let html = "<div>hello</div>"; let mut vd = VD::new(); vd.parse_html(html); println!("{:?}", vd.get_vd()); }<|fim_prefix|>// repo: TtTRz/html2VD path: /src/tests/vd.rs use virtual_dom::VirtualDom; use crate::algo::virtual_dom; use crate::model::vd::VD; <|f...
code_fim
medium
{ "lang": "rust", "repo": "TtTRz/html2VD", "path": "/src/tests/vd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: TtTRz/html2VD path: /src/tests/vd.rs use virtual_dom::VirtualDom; use crate::algo::virtual_dom; use crate::model::vd::VD; #[test] fn test_vd_new() { let vd = VD::new(); println!("{:?}", vd); } <|fim_suffix|> let html = "<div>hello</div>"; let mut vd = VD::new(); vd.parse_ht...
code_fim
easy
{ "lang": "rust", "repo": "TtTRz/html2VD", "path": "/src/tests/vd.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let vd = VD::new(); println!("{:?}", vd); } #[test] fn test_parse_html() { let html = "<div>hello</div>"; let mut vd = VD::new(); vd.parse_html(html); println!("{:?}", vd.get_vd()); }<|fim_prefix|>// repo: TtTRz/html2VD path: /src/tests/vd.rs use virtual_dom::VirtualDom; use cra...
code_fim
easy
{ "lang": "rust", "repo": "TtTRz/html2VD", "path": "/src/tests/vd.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // Can't change value of _mutable_integer until the local immutable one goes out of scope // _mutable_integer = 50; } _mutable_integer = 3; }<|fim_prefix|>// repo: frankhart2018/rust-by-example path: /4-variable-bindings/freezing-5/src/main.rs fn main() { // When data is bou...
code_fim
medium
{ "lang": "rust", "repo": "frankhart2018/rust-by-example", "path": "/4-variable-bindings/freezing-5/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: frankhart2018/rust-by-example path: /4-variable-bindings/freezing-5/src/main.rs fn main() { // When data is bound by the same name immutably, it also freezes // Frozen data can't be modified until the immutable binding goes out of scope <|fim_suffix|> // Can't change value of _m...
code_fim
medium
{ "lang": "rust", "repo": "frankhart2018/rust-by-example", "path": "/4-variable-bindings/freezing-5/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> Result<(), Errno> { syscall0(SYS_SYNC).map(drop) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sync.rs /// Commit filesystem caches to disk. /// /// # Exampl<|fim_middle|>e /// /// ``` /// let ret = unsafe { nc::sync() }; /// assert!(ret.is_ok()); /// ``` pub unsafe fn sync() ->
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/sync.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sync.rs /// Commit filesystem caches to disk. /// /// # Exampl<|fim_suffix|> Result<(), Errno> { syscall0(SYS_SYNC).map(drop) }<|fim_middle|>e /// /// ``` /// let ret = unsafe { nc::sync() }; /// assert!(ret.is_ok()); /// ``` pub unsafe fn sync() ->
code_fim
medium
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/sync.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> assert!(ret.is_ok()); /// ``` pub unsafe fn sync() -> Result<(), Errno> { syscall0(SYS_SYNC).map(drop) }<|fim_prefix|>// repo: XuShaohua/nc path: /src/calls/sync.rs /// Commit filesystem caches to disk. /// /// # Exampl<|fim_middle|>e /// /// ``` /// let ret = unsafe { nc::sync() }; ///
code_fim
easy
{ "lang": "rust", "repo": "XuShaohua/nc", "path": "/src/calls/sync.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: dbcfd/juniper-from-schema path: /juniper-from-schema-code-gen/src/nullable_type.rs use graphql_parser::schema::{Name, Type}; #[derive(Eq, PartialEq, Debug)] pub enum NullableType<'a> { NamedType(&'a Name), ListType(Box<NullableType<'a>>), NullableType(Box<NullableType<'a>>), } impl...
code_fim
hard
{ "lang": "rust", "repo": "dbcfd/juniper-from-schema", "path": "/juniper-from-schema-code-gen/src/nullable_type.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let input = Type::NonNullType(Box::new(Type::ListType(Box::new(Type::NonNullType( Box::new(Type::NamedType("Int".to_string())), ))))); let expected = "List(Int)".to_string(); assert_eq!(map(&input).debug_print(), expected); let input = Type::ListType(Bo...
code_fim
hard
{ "lang": "rust", "repo": "dbcfd/juniper-from-schema", "path": "/juniper-from-schema-code-gen/src/nullable_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match type_ { inner @ Type::NamedType(_) => map_inner(inner, false), Type::ListType(item_type) => { let item_type = map_inner(&*item_type, false); let list = NullableType::ListType(Box::new(item_type)); NullableType::NullableType(Box::new(list)) ...
code_fim
hard
{ "lang": "rust", "repo": "dbcfd/juniper-from-schema", "path": "/juniper-from-schema-code-gen/src/nullable_type.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ResidentMario/hmac-toy path: /src/main.rs use hmac_toy::{hmac_encode, IntegrityVerifiedPackage}; <|fim_suffix|> let pkg: IntegrityVerifiedPackage = hmac_encode("Hello World", "Sekrit"); println!("{:?}", pkg.msg); println!("{:?}", pkg.verify("Sekrit")); }<|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "ResidentMario/hmac-toy", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let pkg: IntegrityVerifiedPackage = hmac_encode("Hello World", "Sekrit"); println!("{:?}", pkg.msg); println!("{:?}", pkg.verify("Sekrit")); }<|fim_prefix|>// repo: ResidentMario/hmac-toy path: /src/main.rs use hmac_toy::{hmac_encode, IntegrityVerifiedPackage}; <|fim_middle|>fn main() {
code_fim
easy
{ "lang": "rust", "repo": "ResidentMario/hmac-toy", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub fn post(state: State) -> Box<HandlerFuture> { // let f = state // .take::<Body>() // .concat2() // .then(|full_body| match full_body { // Ok(valid_body) => { // let body_content = String::from_utf8(valid_body.to_vec()).unwrap(); // ...
code_fim
hard
{ "lang": "rust", "repo": "miyamoen/toy-petshop", "path": "/src/handlers/pets.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: miyamoen/toy-petshop path: /src/handlers/pets.rs use futures::{future, Future, Stream}; use gotham::handler::{HandlerFuture, IntoHandlerError}; use gotham::http::response::create_response; use gotham::state::{FromState, State}; use gotham_serde_json_body_parser::{create_json_response, JSONBody};...
code_fim
hard
{ "lang": "rust", "repo": "miyamoen/toy-petshop", "path": "/src/handlers/pets.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: geoffroyvergne/crawler path: /rust/src/model.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct HttpValues { pub url: String, pub status: u16, #[serde(skip_serializing)] pub content: String, pub headers: std::collections::HashMap<Stri...
code_fim
hard
{ "lang": "rust", "repo": "geoffroyvergne/crawler", "path": "/rust/src/model.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, Serialize, Deserialize)] pub struct WebStatus { pub code: u16, pub message: String }<|fim_prefix|>// repo: geoffroyvergne/crawler path: /rust/src/model.rs use serde::{Deserialize, Serialize}; #[derive(Debug, Serialize, Deserialize)] pub struct HttpValues { pub url: String, ...
code_fim
medium
{ "lang": "rust", "repo": "geoffroyvergne/crawler", "path": "/rust/src/model.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub use de::{from_reader, from_str};<|fim_prefix|>// repo: oasislabs/serde-eth path: /src/lib.rs mod custom_de; mod custom_ser; pub mod de; mod error; mod eth; pub mod ser; mod serde_tests; <|fim_middle|>pub use ser::{to_string, to_vec, to_writer};
code_fim
easy
{ "lang": "rust", "repo": "oasislabs/serde-eth", "path": "/src/lib.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: oasislabs/serde-eth path: /src/lib.rs mod custom_de; mod custom_ser; pub mod de; mod error; mod eth; pub mod ser; mod serde_tests; <|fim_suffix|>pub use de::{from_reader, from_str};<|fim_middle|>pub use ser::{to_string, to_vec, to_writer};
code_fim
easy
{ "lang": "rust", "repo": "oasislabs/serde-eth", "path": "/src/lib.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> match &ast.node { Node::Id { lit } => Ok(TrueName::from(&StringName::from(lit.as_str()))), Node::Tuple { elements } => { let elements: Vec<Name> = elements.iter().map(Name::try_from).collect::<Result<_, _>>()?; Ok(TrueName::tuple(elements.as_...
code_fim
hard
{ "lang": "rust", "repo": "JSAbrahams/mamba", "path": "/src/check/name/true_name/generic.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: JSAbrahams/mamba path: /src/check/name/true_name/generic.rs use std::convert::TryFrom; use std::ops::Deref; use crate::check::name::{Name, Nullable, TupleCallable}; use crate::check::name::string_name::StringName; use crate::check::name::true_name::TrueName; use crate::check::result::{TypeErr, ...
code_fim
hard
{ "lang": "rust", "repo": "JSAbrahams/mamba", "path": "/src/check/name/true_name/generic.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> match dotenv::var(arg) { Ok(var) => var, Err(var_err) => panic!("No such variable {} exists \ndetails : {}", arg, var_err), } } pub async fn task_gateway() -> Gateway { Gateway::establish("TODO_TASK_COLLECTION", fetch_env).await } pub async fn list_gateway() -> Gateway { G...
code_fim
hard
{ "lang": "rust", "repo": "lusamreth/todo_actix", "path": "/src/gateway/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: lusamreth/todo_actix path: /src/gateway/mod.rs mod todo_gateway; use crate::db::Db; use std::future::Future; use std::pin::Pin; pub mod serializer; // no public //take out! pub mod task_gateway; #[allow(dead_code)] pub struct Gateway { col: TodoCol, } // type TodoCol = Bo...
code_fim
hard
{ "lang": "rust", "repo": "lusamreth/todo_actix", "path": "/src/gateway/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> registry.register_helper( "resource_drive_path", Box::new( move |_: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, ...
code_fim
hard
{ "lang": "rust", "repo": "Arstman/graph-rs", "path": "/graph-http/src/registry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Arstman/graph-rs path: /graph-http/src/registry.rs use graph_core::resource::ResourceIdentity; use handlebars::*; #[derive(Default)] pub struct Registry; impl Registry { pub fn register_internal_helper( resource_identity: ResourceIdentity, registry: &mut Handlebars, ) {...
code_fim
hard
{ "lang": "rust", "repo": "Arstman/graph-rs", "path": "/graph-http/src/registry.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(()) }, ), ); registry.register_helper( "resource_drive_path", Box::new( move |_: &Helper, _: &Handlebars...
code_fim
hard
{ "lang": "rust", "repo": "Arstman/graph-rs", "path": "/graph-http/src/registry.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Wassasin/dewi-reservations-ical path: /src/main.rs //! HTTP server that periodically fetches reservations from a Dewi-online sports facility API and yields an ical file. use crate::env::EnvConfiguration; use actix_web::{ client::SendRequestError, web::{self, Data}, App, HttpResponse...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/dewi-reservations-ical", "path": "/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(HttpResponse::Ok() .content_type("text/calendar") .body(calendar.to_string())) } #[derive(Clone)] pub struct Conf(std::sync::Arc<EnvConfiguration>); #[actix_rt::main] async fn main() -> std::io::Result<()> { let configuration = env::get_conf().unwrap(); let socketaddr = co...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/dewi-reservations-ical", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> Ok(Reservation { id, name, start, end, }) } } async fn compute_reservations(conf: &EnvConfiguration) -> Result<Vec<Reservation>> { let params = upstream::login(conf).await?; let data = upstream::get_reservations(conf, &params).aw...
code_fim
hard
{ "lang": "rust", "repo": "Wassasin/dewi-reservations-ical", "path": "/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub type mach_port_right_t = natural_t; pub const MACH_PORT_RIGHT_SEND : mach_port_right_t = 0; pub const MACH_PORT_RIGHT_RECEIVE : mach_port_right_t = 1; pub const MACH_PORT_RIGHT_SEND_ONCE : mach_port_right_t = 2; pub const MACH_PORT_RIGHT_PORT_SET : mach_port_right_t = 3; pub const MACH_PORT_R...
code_fim
medium
{ "lang": "rust", "repo": "azuqua/mach", "path": "/src/port.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_suffix|>pub type mach_port_t = ::libc::c_uint; pub const MACH_PORT_NULL: mach_port_t = 0; pub type mach_port_right_t = natural_t; pub const MACH_PORT_RIGHT_SEND : mach_port_right_t = 0; pub const MACH_PORT_RIGHT_RECEIVE : mach_port_right_t = 1; pub const MACH_PORT_RIGHT_SEND_ONCE : mach_port_right_t = 2...
code_fim
medium
{ "lang": "rust", "repo": "azuqua/mach", "path": "/src/port.rs", "mode": "spm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: azuqua/mach path: /src/port.rs //! This module corresponds to `mach/port.h` use vm_types::{natural_t}; <|fim_suffix|>pub type mach_port_t = ::libc::c_uint; pub const MACH_PORT_NULL: mach_port_t = 0; pub type mach_port_right_t = natural_t; pub const MACH_PORT_RIGHT_SEND : mach_port_righ...
code_fim
medium
{ "lang": "rust", "repo": "azuqua/mach", "path": "/src/port.rs", "mode": "psm", "license": "BSD-2-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: flaper87/rust-mdbm path: /mdbm-sys/src/lib.rs #![allow(non_camel_case_types)] #![allow(non_snake_case)] extern crate libc; <|fim_suffix|>pub const MDBM_O_CREAT: libc::c_int = 0x00000040; pub const MDBM_O_TRUNC: libc::c_int = 0x00000200; pub const MDBM_O_ASYNC: libc::c_int = 0x00002000; pub co...
code_fim
hard
{ "lang": "rust", "repo": "flaper87/rust-mdbm", "path": "/mdbm-sys/src/lib.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>pub const MDBM_INSERT: libc::c_int = 0; pub const MDBM_REPLACE: libc::c_int = 1; pub const MDBM_INSERT_DUP: libc::c_int = 2; pub const MDBM_MODIFY: libc::c_int = 3;<|fim_prefix|>// repo: flaper87/rust-mdbm path: /mdbm-sys/src/lib.rs #![allow(non_camel_case_types)] #![allow(non_snake_case)] extern crate ...
code_fim
medium
{ "lang": "rust", "repo": "flaper87/rust-mdbm", "path": "/mdbm-sys/src/lib.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> s.chars().map(|c| { v[(c as u8 - 'a' as u8) as usize] }).collect() }<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/804_unique_morse_representations.rs impl Solution { pub fn unique_morse_representations(words: Vec<String>) -> i32 { let v = vec![".-","-...","-.-...
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/804_unique_morse_representations.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: HerringtonDarkholme/leetcode path: /src/804_unique_morse_representations.rs impl Solution { pub fn unique_morse_representations(words: Vec<String>) -> i32 { let v = vec![".-","-...","-.-.","-..",".","..-.","--.","....","..",".---","-.-",".-..","--","-.","---",".--.","--.-",".-.","......
code_fim
medium
{ "lang": "rust", "repo": "HerringtonDarkholme/leetcode", "path": "/src/804_unique_morse_representations.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kaaboaye/genetic_algorithm path: /src/population/mod.rs pub mod config; mod individual; mod random_vector; use crate::consts::Number; use crate::population::config::Config; use crate::population::individual::new_individual; use crate::population::random_vector::random_vector; use crate::scenari...
code_fim
hard
{ "lang": "rust", "repo": "kaaboaye/genetic_algorithm", "path": "/src/population/mod.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // it is save because both matrices have the same size unsafe { swap( self.population.data.as_vec_mut(), self.next_population.data.as_vec_mut(), ); } best_individual } } /// Generates and returns random populatio...
code_fim
hard
{ "lang": "rust", "repo": "kaaboaye/genetic_algorithm", "path": "/src/population/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Filter out individuals not meeting the requirements. costs.component_mul_assign(&weights); costs.component_mul_assign(&sizes); costs }) .unwrap() } /// Selects individual using tournament algorithm /// Returns selected individual's index fn tournament(scores: &...
code_fim
hard
{ "lang": "rust", "repo": "kaaboaye/genetic_algorithm", "path": "/src/population/mod.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kHigasa/rustcli path: /echo/echo/src/main.rs extern crate getopts; use getopts::Options; use std::env; fn print_usage(program: &str, opts: Options) { let brief = format!("Usage: {} [OPTION]... [FILE]...", program); print!("{}", opts.usage(&brief)); } <|fim_suffix|> print!("{}\n", i...
code_fim
medium
{ "lang": "rust", "repo": "kHigasa/rustcli", "path": "/echo/echo/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let mut opts = Options::new(); opts.optflag("n", "", "don't output the trailing newline"); opts.optflag("e", "", "enable interpretation of backslash escapes"); opts.optflag("h", "", "print this help menu"); let matches = match opts.parse(&args[1..]) { Ok(m) => { m } Err...
code_fim
medium
{ "lang": "rust", "repo": "kHigasa/rustcli", "path": "/echo/echo/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Collbrothers/sign-logger-rs path: /src/lib.rs use chrono::{Datelike, Timelike, Utc}; macro_rules! ternary { ($c:expr, $v:expr, $v1:expr) => { if $c { $v } else { $v1 } }; } pub struct OverwriteDate { show: bool, format: &'static str...
code_fim
hard
{ "lang": "rust", "repo": "Collbrothers/sign-logger-rs", "path": "/src/lib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> println!( "{} {}{}{}{}{}{}{}{}{}{}{}", self.date_format(format), color, res.0, ternary!(options.underline, Colors::UNDERLINE.resolve(), ""), ternary!( name.to_lowercase() == "fatal", format!("\...
code_fim
hard
{ "lang": "rust", "repo": "Collbrothers/sign-logger-rs", "path": "/src/lib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: reem/rust-euler path: /prob4.rs #[allow(deprecated_owned_vector)]; extern crate test; #[cfg(not(test))] fn main() { println!("{}", prob4(100, 999)); } fn reverse(num: uint) -> uint { let mut reversed = 0; let mut n = num; while n > 0 { reversed = 10*reversed + n % 10; ...
code_fim
medium
{ "lang": "rust", "repo": "reem/rust-euler", "path": "/prob4.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> assert!(reverse(123456) == 654321); assert!(reverse(1) == 1); assert!(reverse(101) == 101); } #[test] fn test_is_palindrome() { assert!(!is_palindrome(10)); assert!(is_palindrome(1001)); assert!(is_palindrome(1)); } #[test] fn test_prob4() { assert!(prob4(10, 99) == 9009); } ...
code_fim
hard
{ "lang": "rust", "repo": "reem/rust-euler", "path": "/prob4.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: simonhdickson/wilde path: /examples/simple_consumer.rs extern crate capnp; #[macro_use] extern crate capnp_rpc; extern crate futures; extern crate tokio_core; extern crate tokio_io; use capnp_rpc::{RpcSystem, twoparty, rpc_twoparty_capnp}; use wilde_capnp::{consumer, consumer_function}; use ca...
code_fim
hard
{ "lang": "rust", "repo": "simonhdickson/wilde", "path": "/examples/simple_consumer.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> let addr = args[2].to_socket_addrs().unwrap().next().expect("could not parse address"); let stream = core.run(::tokio_core::net::TcpStream::connect(&addr, &handle)).unwrap(); stream.set_nodelay(true).unwrap(); let (reader, writer) = stream.split(); let rpc_network = Box::new(twoparty:...
code_fim
hard
{ "lang": "rust", "repo": "simonhdickson/wilde", "path": "/examples/simple_consumer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> results.get().set_processed(true); Promise::ok(()) } } pub fn main() { use std::net::ToSocketAddrs; let args: Vec<String> = ::std::env::args().collect(); if args.len() != 3 { println!("usage: {} client HOST:PORT", args[0]); return; } let mut core =...
code_fim
hard
{ "lang": "rust", "repo": "simonhdickson/wilde", "path": "/examples/simple_consumer.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: kiwiyou/craftping path: /examples/async-std.rs use async_std::net::TcpStream; use craftping::futures::ping; #[async_std::main] async fn main() -> craftping::Result<()> { let servers = ["us.mineplex.com", "mc.hypixel.net"]; for &server in servers.iter() { <|fim_suffix|>, 25565).awai...
code_fim
medium
{ "lang": "rust", "repo": "kiwiyou/craftping", "path": "/examples/async-std.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|>, 25565).await?; println!("ping to {}:", server); println!("{:?}", response); } Ok(()) }<|fim_prefix|>// repo: kiwiyou/craftping path: /examples/async-std.rs use async_std::net::TcpStream; use craftping::futures::ping; #[async_std::main] async fn main() -> craftping::<|fim_middle...
code_fim
hard
{ "lang": "rust", "repo": "kiwiyou/craftping", "path": "/examples/async-std.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: luqz/cita-common path: /jsonrpc-types/src/rpc_types/block.rs // Copyright Cryptape Technologies LLC. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://w...
code_fim
hard
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/jsonrpc-types/src/rpc_types/block.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct BlockBody { pub transactions: Vec<BlockTransaction>, } #[derive(Debug, PartialEq, Clone, Serialize, Deserialize)] pub struct BlockHeader { pub timestamp: u64, #[serde(rename = "prevHash")] pub prev_hash: H256, pub n...
code_fim
medium
{ "lang": "rust", "repo": "luqz/cita-common", "path": "/jsonrpc-types/src/rpc_types/block.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ulbora/ccount_service path: /tests/category_test.rs use ccount_service::establish_pooled_connection; use ccount_service::category::add_new_category; use ccount_service::category::delete_existing_category; use ccount_service::category::get_category_list; use ccount_service::category::update_exis...
code_fim
medium
{ "lang": "rust", "repo": "Ulbora/ccount_service", "path": "/tests/category_test.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> let cats = get_category_list(&ncon.get().unwrap()); assert!(cats.len() >= 1); let res = delete_existing_category(&ncon.get().unwrap(), cat.id); assert!(res.unwrap() == 1); } }<|fim_prefix|>// repo: Ulbora/ccount_service path: /tests/category_test.rs use ccount_service...
code_fim
medium
{ "lang": "rust", "repo": "Ulbora/ccount_service", "path": "/tests/category_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn new_category() { let ncon = establish_pooled_connection(); let cat = add_new_category(&ncon.get().unwrap(), "beans"); assert!(cat.name == "beans"); let cat = update_existing_category(&ncon.get().unwrap(), cat.id, "black beans"); assert!(cat.name ...
code_fim
medium
{ "lang": "rust", "repo": "Ulbora/ccount_service", "path": "/tests/category_test.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: rust-chainblock/mitrid-core path: /src/io/network/client/mod.rs //! # Client //! //! `client` is the module providing the network client types and traits. /// Type used to represent the client behavior on error responses. pub mod on_error; <|fim_suffix|>pub use self::on_error::OnError; pub use...
code_fim
easy
{ "lang": "rust", "repo": "rust-chainblock/mitrid-core", "path": "/src/io/network/client/mod.rs", "mode": "psm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|>pub use self::on_error::OnError; pub use self::client::Client;<|fim_prefix|>// repo: rust-chainblock/mitrid-core path: /src/io/network/client/mod.rs //! # Client //! //! `client` is the module providing the network client types and traits. /// Type used to represent the client behavior on error response...
code_fim
easy
{ "lang": "rust", "repo": "rust-chainblock/mitrid-core", "path": "/src/io/network/client/mod.rs", "mode": "spm", "license": "Apache-2.0", "source": "the-stack-v2" }
<|fim_suffix|> fn get_patches(state: web::Data<AppState>) -> impl Responder { match state.patch_manager.patches() { Ok(p) => HttpResponse::Ok() .content_type("application/json") .body(serde_json::to_string(&p).unwrap()), Err(s) => HttpResponse::InternalServerError() ....
code_fim
hard
{ "lang": "rust", "repo": "manueldeval/synth", "path": "/src/web/webserver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>fn dspnodes() -> impl Responder { HttpResponse::Ok() .content_type("application/json") .body(serde_json::to_string(&AudioNodeRegistry::node_infos()).unwrap()) } fn command(state: web::Data<AppState>,commands: web::Json<Vec<SystemCommand>>) -> impl Responder { commands .iter() ....
code_fim
hard
{ "lang": "rust", "repo": "manueldeval/synth", "path": "/src/web/webserver.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: manueldeval/synth path: /src/web/webserver.rs use std::thread; use std::thread::JoinHandle; use actix_web::{web, App, HttpResponse, HttpServer, Responder}; use actix_files as fs; use crossbeam::crossbeam_channel::Sender; use crate::synth::dsp::registry::AudioNodeRegistry; use crate::synth::com...
code_fim
hard
{ "lang": "rust", "repo": "manueldeval/synth", "path": "/src/web/webserver.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: nrf-rs/nrf-pacs path: /pacs/nrf52820-pac/src/radio/rssisample.rs #[doc = "Register `RSSISAMPLE` reader"] pub struct R(crate::R<RSSISAMPLE_SPEC>); impl core::ops::Deref for R { type Target = crate::R<RSSISAMPLE_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { <|fim_suffix|>...
code_fim
medium
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf52820-pac/src/radio/rssisample.rs", "mode": "psm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_suffix|> R(reader) } } #[doc = "Field `RSSISAMPLE` reader - RSSI sample."] pub type RSSISAMPLE_R = crate::FieldReader<u8, u8>; impl R { #[doc = "Bits 0:6 - RSSI sample."] #[inline(always)] pub fn rssisample(&self) -> RSSISAMPLE_R { RSSISAMPLE_R::new((self.bits & 0x7f) as u8) } }...
code_fim
medium
{ "lang": "rust", "repo": "nrf-rs/nrf-pacs", "path": "/pacs/nrf52820-pac/src/radio/rssisample.rs", "mode": "spm", "license": "0BSD", "source": "the-stack-v2" }
<|fim_prefix|>// repo: gskapka/rust-sgx-db-shim path: /app/src/ecall_api.rs use sgx_types::{ sgx_status_t, sgx_enclave_id_t, }; ext<|fim_suffix|>u8, scratch_pad_size: *const u8, ) -> sgx_status_t; }<|fim_middle|>ern { pub fn run_sample( eid: sgx_enclave_id_t, retval: *mut sgx_s...
code_fim
medium
{ "lang": "rust", "repo": "gskapka/rust-sgx-db-shim", "path": "/app/src/ecall_api.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>u8, scratch_pad_size: *const u8, ) -> sgx_status_t; }<|fim_prefix|>// repo: gskapka/rust-sgx-db-shim path: /app/src/ecall_api.rs use sgx_types::{ sgx_status_t, sgx_enclave_id_t, }; extern { pub fn run_sample( eid: sgx_enclave_id_t, <|fim_middle|> retval: *mut sgx_s...
code_fim
medium
{ "lang": "rust", "repo": "gskapka/rust-sgx-db-shim", "path": "/app/src/ecall_api.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> if !crate::buffer::same_scope(self.cursor(), fork.cursor()) { panic!("Fork was not derived from the advancing parse stream"); } let (self_unexp, self_sp) = inner_unexpected(self); let (fork_unexp, fork_sp) = inner_unexpected(fork); if !Rc::ptr_eq(&self_...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/syn/v1/crate/src/discouraged.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_prefix|>// repo: chromium/chromium path: /third_party/rust/syn/v1/crate/src/discouraged.rs //! Extensions to the parsing API with niche applicability. use super::*; /// Extensions to the `ParseStream` API to support speculative parsing. pub trait Speculative { /// Advance this parse stream to the position ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/syn/v1/crate/src/discouraged.rs", "mode": "psm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> let (self_unexp, self_sp) = inner_unexpected(self); let (fork_unexp, fork_sp) = inner_unexpected(fork); if !Rc::ptr_eq(&self_unexp, &fork_unexp) { match (fork_sp, self_sp) { // Unexpected set on the fork, but not on `self`, copy it over. ...
code_fim
hard
{ "lang": "rust", "repo": "chromium/chromium", "path": "/third_party/rust/syn/v1/crate/src/discouraged.rs", "mode": "spm", "license": "BSD-3-Clause", "source": "the-stack-v2" }
<|fim_suffix|> &CHAT_REGEX } async fn complete(&self, instance: &GroupedRegexMatches<'_>) { let (user, message) = ( instance.captures.at(0, "user").unwrap(), instance.captures.at(0, "message").unwrap(), ); info!("{}: {}", user, message); let messag...
code_fim
hard
{ "lang": "rust", "repo": "brickadia-community/brixide", "path": "/server/src/matchers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> &JOIN_REGEX } async fn complete(&self, instance: &GroupedRegexMatches<'_>) { let name = instance.captures.at(1, "user").unwrap(); let uuid: Uuid = instance.captures.at(2, "id").unwrap().parse().unwrap(); let player = Player { name: name.into(), ...
code_fim
hard
{ "lang": "rust", "repo": "brickadia-community/brixide", "path": "/server/src/matchers.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brickadia-community/brixide path: /server/src/matchers.rs use std::{collections::HashMap, fmt, sync::Arc, time::Duration}; use async_trait::async_trait; use lazy_static::lazy_static; use log::info; use plugin::{payloads::*, player::Player, rpc}; use regex::Regex; use serde::{Deserialize, Serial...
code_fim
hard
{ "lang": "rust", "repo": "brickadia-community/brixide", "path": "/server/src/matchers.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ChristianNoelSchmid/Pathfinding path: /src/io.rs use std::io; use std::io::Write; /// /// Recieves user input and returns /// pub fn input(same_line: bool) -> String { // Print a input prompt; if !same_line { print!(" >> "); } io::stdout().flush().unwrap(); <|fi...
code_fim
hard
{ "lang": "rust", "repo": "ChristianNoelSchmid/Pathfinding", "path": "/src/io.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|> // Trim the '\n' off end of String (since // read_line writes end-line onto String) return format!("{}", inp.trim_end_matches('\n')); } /// /// Waits for user to press ENTER before continuing /// pub fn wait_for_enter() { print!("Press ENTER to continue..."); let _ = input(true); } ...
code_fim
medium
{ "lang": "rust", "repo": "ChristianNoelSchmid/Pathfinding", "path": "/src/io.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: brmmm3/RustTaskBarProgress path: /src/TaskbarLib.rs #![allow(non_camel_case_types, non_snake_case, unused)] use winapi::ctypes::c_void; use winapi::shared::minwindef::UINT; use winapi::shared::winerror::HRESULT; use winapi::shared::wtypes::{BSTR, VARIANT_BOOL}; use winapi::um::oaidl::{IDispatch...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/RustTaskBarProgress", "path": "/src/TaskbarLib.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>ENUM! {enum TBPFLAG { TBPF_NOPROGRESS = 0, TBPF_INDETERMINATE = 1, TBPF_NORMAL = 2, TBPF_ERROR = 4, TBPF_PAUSED = 8, }} pub type wireHWND = *mut _RemotableHandle; STRUCT! {struct _RemotableHandle { fContext: i32, u: __MIDL_IWinTypes_0009, }} UNION! {union __MIDL_IWinTypes_00...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/RustTaskBarProgress", "path": "/src/TaskbarLib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_suffix|>pub type GUID = __MIDL___MIDL_itf_TaskbarLib_0006_0001_0001; STRUCT! {struct __MIDL___MIDL_itf_TaskbarLib_0006_0001_0001 { Data1: u32, Data2: u16, Data3: u16, Data4: [u8; 8], }} RIDL! {#[uuid(0x602d4995, 0xb13a, 0x429b, 0xa6, 0x6e, 0x19, 0x35, 0xe4, 0x4f, 0x43, 0x17)] interface ITaskbarL...
code_fim
hard
{ "lang": "rust", "repo": "brmmm3/RustTaskBarProgress", "path": "/src/TaskbarLib.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: duskmoon314/aw-pac path: /d1-pac/src/tcon_lcd0/lcd_cpu_tri1.rs #[doc = "Register `lcd_cpu_tri1` reader"] pub struct R(crate::R<LCD_CPU_TRI1_SPEC>); impl core::ops::Deref for R { type Target = crate::R<LCD_CPU_TRI1_SPEC>; #[inline(always)] fn deref(&self) -> &Self::Target { &s...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/tcon_lcd0/lcd_cpu_tri1.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> W(writer) } } #[doc = "Field `block_num` reader - The number of data blocks. It is usually set as Y."] pub type BLOCK_NUM_R = crate::FieldReader<u16, u16>; #[doc = "Field `block_num` writer - The number of data blocks. It is usually set as Y."] pub type BLOCK_NUM_W<'a, const O: u8> = crate...
code_fim
hard
{ "lang": "rust", "repo": "duskmoon314/aw-pac", "path": "/d1-pac/src/tcon_lcd0/lcd_cpu_tri1.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> if *menu_cursor < max_field { *menu_cursor += 1; } else { *menu_cursor = 0; } } MenuAction::Select => { menu[*menu_cursor].do_action(game_mode, menu_cursor); ...
code_fim
hard
{ "lang": "rust", "repo": "jamiebidelia/star_slammers", "path": "/src/menuaction.rs", "mode": "spm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: jamiebidelia/star_slammers path: /src/menuaction.rs /* _____ _ _____ _ / ____| | / ____| | _ | (___ | |_ __ _ _ __ | (___ | | __ _ _ __ ___ _ __ ___ ___ ...
code_fim
hard
{ "lang": "rust", "repo": "jamiebidelia/star_slammers", "path": "/src/menuaction.rs", "mode": "psm", "license": "Unlicense", "source": "the-stack-v2" }
<|fim_prefix|>// repo: static-web-server/iron-test path: /examples/router_test.rs extern crate iron; extern crate iron_test; extern crate router; use iron::{Handler, status}; use iron::prelude::*; use router::Router; struct RouterHandler; impl Handler for RouterHandler { fn handle(&self, req: &mut Request) -> ...
code_fim
medium
{ "lang": "rust", "repo": "static-web-server/iron-test", "path": "/examples/router_test.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> #[test] fn test_router() { let response = request::get("http://localhost:3000/1", Headers::new(), &app_router()); let result = extract_body_to_bytes(response.unwrap()); assert_eq!(result, b"1"); } ...
code_fim
hard
{ "lang": "rust", "repo": "static-web-server/iron-test", "path": "/examples/router_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> use iron_test::{request, response}; use router::Router; use super::{app_router, RouterHandler}; #[test] fn test_router() { let response = request::get("http://localhost:3000/1", Headers::new(), &app_rout...
code_fim
hard
{ "lang": "rust", "repo": "static-web-server/iron-test", "path": "/examples/router_test.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // 询问时间是否发生 manager.retrieve(&mut events, timeout)?; loop { match events.pop() { Some(_) => { eprintln!("正在返回数据..."); let (mut stream, _) = listener.accept().unwrap(); stream.write(b"HTTP/1.1 2...
code_fim
hard
{ "lang": "rust", "repo": "DingDean/nonblocking_io", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: DingDean/nonblocking_io path: /src/main.rs /// Nio: nonblocking i/o /// ```no_run /// ``` use libc; use nio::{Interest, Manager}; use std::io::prelude::*; use std::net::TcpListener; #[cfg(unix)] use std::os::unix::io::AsRawFd; use std::time::Duration; <|fim_suffix|> loop { let timeou...
code_fim
hard
{ "lang": "rust", "repo": "DingDean/nonblocking_io", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: ajbt200128/e310x path: /src/common/pwm0.rs #[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - PWM Configuration Register"] pub cfg: CFG, _reserved1: [u8; 4usize], #[doc = "0x08 - Counter Register"] pub count: COUNT, _reserved2: [u8; 4usize], ...
code_fim
hard
{ "lang": "rust", "repo": "ajbt200128/e310x", "path": "/src/common/pwm0.rs", "mode": "psm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|>:read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [cmp0](cmp0)...
code_fim
hard
{ "lang": "rust", "repo": "ajbt200128/e310x", "path": "/src/common/pwm0.rs", "mode": "spm", "license": "ISC", "source": "the-stack-v2" }
<|fim_suffix|> let request = String::from_utf8_lossy(&peek_buffer[..]); let content_length = get_content_length(&request); let buffer_size = if content_length > request_size { content_length + 512 } else { request_size }; let mut buffer = vec![0; buffer_size]; s.read(&mut buffer).unwrap(); ...
code_fim
medium
{ "lang": "rust", "repo": "Ajhaa/rust_server", "path": "/src/main.rs", "mode": "spm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Ajhaa/rust_server path: /src/main.rs extern crate buffer; extern crate regex; use regex::Regex; use std::io::prelude::*; use std::net::{TcpListener, TcpStream}; fn main() { <|fim_suffix|> println!("{}", full_request); println!("Data: {}", request_data(&full_request)); s.write("Hello wor...
code_fim
hard
{ "lang": "rust", "repo": "Ajhaa/rust_server", "path": "/src/main.rs", "mode": "psm", "license": "unknown", "source": "the-stack-v2" }
<|fim_prefix|>// repo: Kaikallon/stm32-hal path: /examples/conductivity_module/src/main.rs //! This is the entry point for firmware for the //! [AnyLeaf conductivity](https://www.anyleaf.org/ec-module) module. //! Conductivity-measuring code is in `ec.rs`. #![no_main] #![no_std] #![allow(non_snake_case)] use core::{...
code_fim
hard
{ "lang": "rust", "repo": "Kaikallon/stm32-hal", "path": "/examples/conductivity_module/src/main.rs", "mode": "psm", "license": "MIT", "source": "the-stack-v2" }
<|fim_suffix|> // todo: You could probably use the onboard ADC to reduce cost and hardware complexity. // todo: Precision voltage ref on VDDA and VSSA, to improve accuracy? // set up the DAC, to control voltage into the conductivity circuit. let dac = Dac::new(dp.DAC1, DacDevice::One, DacBits::TwelveR, ...
code_fim
hard
{ "lang": "rust", "repo": "Kaikallon/stm32-hal", "path": "/examples/conductivity_module/src/main.rs", "mode": "spm", "license": "MIT", "source": "the-stack-v2" }