text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: bdalrhm/rmc path: /compiler/rustc_codegen_llvm/src/gotoc/cbmc/irep/irep.rs
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
//! The actual `Irep` structure, and associated constructors, getters, and setters.
use super::super::go... | code_fim | hard | {
"lang": "rust",
"repo": "bdalrhm/rmc",
"path": "/compiler/rustc_codegen_llvm/src/gotoc/cbmc/irep/irep.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JayceFayne/libfj path: /tests/techblox_parsing.rs
#[cfg(feature = "techblox")]
use libfj::techblox;
#[cfg(feature = "techblox")]
use libfj::techblox::{SerializedEntityDescriptor, Parsable, blocks, EntityHeader};
#[cfg(feature = "techblox")]
use std::io::{Read, Seek};
#[cfg(feature = "techblox")]... | code_fim | hard | {
"lang": "rust",
"repo": "JayceFayne/libfj",
"path": "/tests/techblox_parsing.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> //println!("Parsed Phycam hash: {}", gs.phycam_header.hash);
assert_eq!(gs.phycam_header.hash, EntityHeader::from_name("CharacterCameraEntityDescriptorV1", 0, 0, 0).hash);
assert_eq!(gs.phycam_header.hash, gs.phycam_entity.hash_name());
println!("{}", gs.to_string());
Ok(())
}
#[allo... | code_fim | hard | {
"lang": "rust",
"repo": "JayceFayne/libfj",
"path": "/tests/techblox_parsing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut in_file = File::open(GAMESAVE_PATH_ALL).map_err(|_| ())?;
let mut buf = Vec::new();
in_file.read_to_end(&mut buf).map_err(|_| ())?;
let gs = techblox::GameSave::parse(&mut buf.as_slice()).map_err(|_| ())?;
// verify
for i in 1..(gs.group_len as usize) {
assert_eq!(... | code_fim | hard | {
"lang": "rust",
"repo": "JayceFayne/libfj",
"path": "/tests/techblox_parsing.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> temp: i32,
pub ts: DateTime<Utc>,
}<|fim_prefix|>// repo: tabor-lukasz/smart-home-rust path: /src/bin/data_provider/common_structs.rs
use chrono::Utc;
use chrono::DateTime;
<|fim_middle|>// use serde::Serialize;
#[derive(Debug,Clone)]
pub struct TempWithTs {
pub | code_fim | medium | {
"lang": "rust",
"repo": "tabor-lukasz/smart-home-rust",
"path": "/src/bin/data_provider/common_structs.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tabor-lukasz/smart-home-rust path: /src/bin/data_provider/common_structs.rs
use chrono::Utc;
use chrono::DateTime;
// use serde::Serialize;
#[derive(Debug<|fim_suffix|> temp: i32,
pub ts: DateTime<Utc>,
}<|fim_middle|>,Clone)]
pub struct TempWithTs {
pub | code_fim | easy | {
"lang": "rust",
"repo": "tabor-lukasz/smart-home-rust",
"path": "/src/bin/data_provider/common_structs.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: astraw/framed-serial path: /src/lib.rs
//! Add frames to serial connections. Useful for embedded devices. Can be built with `no_std`.
//!
//! The main type of interest is [`FramedConnection`](struct.FramedConnection.html), which takes ownership
//! of a serial connection and allows sending and r... | code_fim | hard | {
"lang": "rust",
"repo": "astraw/framed-serial",
"path": "/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if frame.len() > u16::max_value() as usize {
return Err(Error::new("frame data too long".into()));
}
let mut buf = [0; 2];
byteorder::LittleEndian::write_u16(&mut buf, frame.len() as u16);
self.send_state = SendState::Sending( {
SendingState{... | code_fim | hard | {
"lang": "rust",
"repo": "astraw/framed-serial",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<S> FramedConnection<S>
where S : NonBlockingRx + NonBlockingTx,
{
/// Create a new `FramedConnection`. Takes ownership of the serial device.
pub fn new(s:S) -> FramedConnection<S> {
FramedConnection {
serial:s,
recv_buf: Vec::new(),
recv_state: ... | code_fim | hard | {
"lang": "rust",
"repo": "astraw/framed-serial",
"path": "/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn assert_get_resource_from_str_no_errors(s: &str) -> FluentResource {
FluentResource::try_new(s.to_owned()).expect("Failed to parse an FTL resource.")
}
pub fn assert_get_bundle_no_errors<'a, R: Borrow<FluentResource>>(
res: R,
locale: Option<&str>,
) -> FluentBundle<R> {
let mut bun... | code_fim | hard | {
"lang": "rust",
"repo": "Manishearth/fluent-rs",
"path": "/fluent-bundle/tests/helpers/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Manishearth/fluent-rs path: /fluent-bundle/tests/helpers/mod.rs
use std::borrow::Borrow;
use std::borrow::Cow;
use fluent_bundle::bundle::Message;
use fluent_bundle::errors::FluentError;
use fluent_bundle::{FluentBundle, FluentResource};
#[allow(dead_code)]
pub fn assert_format_none(result: Op... | code_fim | hard | {
"lang": "rust",
"repo": "Manishearth/fluent-rs",
"path": "/fluent-bundle/tests/helpers/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> W(writer)
}
}
#[doc = "Field `IRC40KEN` reader - IRC40K enable"]
pub type IRC40KEN_R = crate::BitReader<bool>;
#[doc = "Field `IRC40KEN` writer - IRC40K enable"]
pub type IRC40KEN_W<'a, const O: u8> = crate::BitWriter<'a, u32, RSTSCK_SPEC, bool, O>;
#[doc = "Field `IRC40KSTB` reader - IRC40K s... | code_fim | hard | {
"lang": "rust",
"repo": "riscv-rust/gd32vf103-pac",
"path": "/src/rcu/rstsck.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riscv-rust/gd32vf103-pac path: /src/rcu/rstsck.rs
#[doc = "Register `RSTSCK` reader"]
pub struct R(crate::R<RSTSCK_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<RSTSCK_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crate::... | code_fim | hard | {
"lang": "rust",
"repo": "riscv-rust/gd32vf103-pac",
"path": "/src/rcu/rstsck.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> SandboxFileNotFound,
}<|fim_prefix|>// repo: siku2/yew-playground path: /protocol/src/error.rs
use serde::{Deserialize, Serialize};
<|fim_middle|>#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum Error {
InternalError(String),
SessionNotFound,
| code_fim | medium | {
"lang": "rust",
"repo": "siku2/yew-playground",
"path": "/protocol/src/error.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siku2/yew-playground path: /protocol/src/error.rs
use serde::{Deserialize, Serialize};
<|fim_suffix|> SessionNotFound,
SandboxFileNotFound,
}<|fim_middle|>#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum Error {
InternalError(String),
| code_fim | medium | {
"lang": "rust",
"repo": "siku2/yew-playground",
"path": "/protocol/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: siku2/yew-playground path: /protocol/src/error.rs
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "type")]
pub enum Error {
InternalError(String),
<|fim_suffix|> SandboxFileNotFound,
}<|fim_middle|> SessionNotFound,
| code_fim | easy | {
"lang": "rust",
"repo": "siku2/yew-playground",
"path": "/protocol/src/error.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daviscai/crab path: /src/view/component/base/theme.rs
#[derive(Clone)]
pub struct Theme {
}
impl Theme {
pub fn new(theme:&str) -> String {
match theme {
"bootstrap" => Theme::create_theme_bootstrap(),
"clean" => Theme::create_theme_clean(),
_ ... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/view/component/base/theme.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
* Bootstrap v4.5.0 (https://getbootstrap.com/)
* Copyright 2011-2020 The Bootstrap Authors
* Copyright 2011-2020 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
fn create_theme_bootstrap() -> String {
r#"
... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/view/component/base/theme.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> r#"
"#.to_string()
}
fn create_theme_clean() -> String {
r#"
"#.to_string()
}
}<|fim_prefix|>// repo: daviscai/crab path: /src/view/component/base/theme.rs
#[derive(Clone)]
pub struct Theme {
}
impl Theme {
pub fn new(theme:&str) -> S... | code_fim | hard | {
"lang": "rust",
"repo": "daviscai/crab",
"path": "/src/view/component/base/theme.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Iterator for StepIterator {
type Item = Step;
fn next(&mut self) -> Option<Self::Item> {
if self.steps_map.len() == 0 {
return None;
}
Some(self.get_next_step())
}
}<|fim_prefix|>// repo: levnikmyskin/adventofcode path: /day_7/src/decision_maker.rs
us... | code_fim | hard | {
"lang": "rust",
"repo": "levnikmyskin/adventofcode",
"path": "/day_7/src/decision_maker.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: levnikmyskin/adventofcode path: /day_7/src/decision_maker.rs
use std::collections::HashMap;
use crate::{Step, Dependencies};
pub struct StepIterator {
steps_map: HashMap<Step, Dependencies>
}
impl StepIterator {
pub fn new(steps_map: HashMap<Step, Dependencies>) -> StepIterator {
... | code_fim | hard | {
"lang": "rust",
"repo": "levnikmyskin/adventofcode",
"path": "/day_7/src/decision_maker.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>nership of what
// it refers to, nothing happens.<|fim_prefix|>// repo: marcelo-a/fp-rust-book path: /examples/book_04_02_03_safely_out_of_scope/source.rs
fn calculate_length(s: &String) -> usize { // s is a reference to a String
s.len()
} // Here, s <|fim_middle|>goes out of scope. But because it ... | code_fim | easy | {
"lang": "rust",
"repo": "marcelo-a/fp-rust-book",
"path": "/examples/book_04_02_03_safely_out_of_scope/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>goes out of scope. But because it does not have ownership of what
// it refers to, nothing happens.<|fim_prefix|>// repo: marcelo-a/fp-rust-book path: /examples/book_04_02_03_safely_out_of_scope/source.rs
fn calculate_length(s: &String) -> usize { // s is<|fim_middle|> a reference to a String
s.len... | code_fim | easy | {
"lang": "rust",
"repo": "marcelo-a/fp-rust-book",
"path": "/examples/book_04_02_03_safely_out_of_scope/source.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcelo-a/fp-rust-book path: /examples/book_04_02_03_safely_out_of_scope/source.rs
fn calculate_length(s: &String) -> usize { // s is<|fim_suffix|>goes out of scope. But because it does not have ownership of what
// it refers to, nothing happens.<|fim_middle|> a reference to a String
s.len... | code_fim | easy | {
"lang": "rust",
"repo": "marcelo-a/fp-rust-book",
"path": "/examples/book_04_02_03_safely_out_of_scope/source.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: LollipopFt/rust_codeforces path: /unrankedproblemset/folder/theatresq.rs
fn main() {
let mut input: String = String::new();
std::io::stdin().read_line(&mut input).expect("Error.");
let input: Vec<&str> = input.trim().split_whitespace().collect();
let mut numvec: Vec<u64> = vec![]... | code_fim | medium | {
"lang": "rust",
"repo": "LollipopFt/rust_codeforces",
"path": "/unrankedproblemset/folder/theatresq.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if numvec[pos]%numvec[numvec.len()-1]!=0 {
1
} else {
0
}
}<|fim_prefix|>// repo: LollipopFt/rust_codeforces path: /unrankedproblemset/folder/theatresq.rs
fn main() {
let mut input: String = String::new();
std::io::stdin().read_line(&mut input).expect("Error.");
le... | code_fim | medium | {
"lang": "rust",
"repo": "LollipopFt/rust_codeforces",
"path": "/unrankedproblemset/folder/theatresq.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JonnyWalker81/rusty_fit path: /src/decoder.rs
extern crate byteorder;
extern crate chrono;
use std::io::Read;
use std::fs;
use std::path::Path;
use byteorder::{ByteOrder, BigEndian, LittleEndian, ReadBytesExt};
use std::collections::HashMap;
use chrono::*;
use super::fit_header::FitHeader;
use s... | code_fim | hard | {
"lang": "rust",
"repo": "JonnyWalker81/rusty_fit",
"path": "/src/decoder.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // let global_message = self.global_mesage_table.get(global_message_number);
let global_message = global_table.get(global_message_number);
// let mut message_mapping: HashMap<i32, &'static str> = HashMap::new();
let mut message_mapping: Rc<FieldTableEntry> = Rc::new(FileIdT... | code_fim | hard | {
"lang": "rust",
"repo": "JonnyWalker81/rusty_fit",
"path": "/src/decoder.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ederoyd46/rust-serverless path: /packages/lib/src/types/error.rs
use std::fmt;
#[derive(Debug)]
pub struct AppError {
pub kind: String,
pub message: String,
}
impl fmt::Display for AppError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
<|fim_suffix|>// Implement std::con... | code_fim | medium | {
"lang": "rust",
"repo": "ederoyd46/rust-serverless",
"path": "/packages/lib/src/types/error.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> write!(
f,
"AppError {{ kind: {}, message: {} }}",
self.kind, self.message
)
}
}
// Implement std::convert::From for AppError; from io::Error
// impl From<io::Error> for AppError {
// fn from(error: io::Error) -> Self {
// AppError {
// ... | code_fim | medium | {
"lang": "rust",
"repo": "ederoyd46/rust-serverless",
"path": "/packages/lib/src/types/error.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_walls_and_gates() {
let mut src: Vec<Vec<i32>> = vec![
vec![INF, -1, 0, INF],
vec![INF, INF, INF , -1],
vec![INF, -1, INF, -1],
vec![0, -1, INF, INF]
];
let target: Vec<Vec<i32>> = vec![
vec![3, -... | code_fim | hard | {
"lang": "rust",
"repo": "weworld/rusty-leetcode",
"path": "/src/search_tag/walls_and_gates_286.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: weworld/rusty-leetcode path: /src/search_tag/walls_and_gates_286.rs
/*
* @lc app=leetcode.cn id=286 lang=rust
*
* [286] 墙与门
*/
// @lc code=start
use std::collections::VecDeque;
use std::mem::swap;
const MOVEMENTS: [(isize, isize);4] = [
(1, 0), (-1,0), (0, 1), (0, -1)
];
const INF: i32 ... | code_fim | hard | {
"lang": "rust",
"repo": "weworld/rusty-leetcode",
"path": "/src/search_tag/walls_and_gates_286.rs",
"mode": "psm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut src: Vec<Vec<i32>> = vec![
vec![INF, -1, 0, INF],
vec![INF, INF, INF , -1],
vec![INF, -1, INF, -1],
vec![0, -1, INF, INF]
];
let target: Vec<Vec<i32>> = vec![
vec![3, -1, 0, 1],
vec![2, 2, 1, ... | code_fim | hard | {
"lang": "rust",
"repo": "weworld/rusty-leetcode",
"path": "/src/search_tag/walls_and_gates_286.rs",
"mode": "spm",
"license": "WTFPL",
"source": "the-stack-v2"
} |
<|fim_suffix|>
}
#[derive(Clone, Copy, Debug)]
pub struct Size2 {
pub w: u32,
pub h: u32,
}<|fim_prefix|>// repo: shmutalov/tick-tack-toe-killer-rs path: /src/system/core/types.rs
#[derive(Clone, Copy, Debug)]
pub struct W<|fim_middle|>indowSize {
pub w: u32,
pub h: u32, | code_fim | easy | {
"lang": "rust",
"repo": "shmutalov/tick-tack-toe-killer-rs",
"path": "/src/system/core/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shmutalov/tick-tack-toe-killer-rs path: /src/system/core/types.rs
#[derive(Clone, Copy, Debug)]
pub struct WindowSize {
pub w: u32,
pub h: u32,<|fim_suffix|>t Size2 {
pub w: u32,
pub h: u32,
}<|fim_middle|>
}
#[derive(Clone, Copy, Debug)]
pub struc | code_fim | easy | {
"lang": "rust",
"repo": "shmutalov/tick-tack-toe-killer-rs",
"path": "/src/system/core/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: treetips/project-euler path: /rust/src/p001.rs
/// # [Problem 1 「3と5の倍数」](http://odz.sakura.ne.jp/projecteuler/?Problem+1)
/// ## Description
/// ```txt
/// 10未満の自然数のうち, 3 もしくは 5 の倍数になっているものは 3, 5, 6, 9 の4つがあり, これらの合計は 23 になる。
/// 同じようにして, 1000 未満の 3 か 5 の倍数になっている数字の合計を求めよ。
/// ```
fn problem_00... | code_fim | medium | {
"lang": "rust",
"repo": "treetips/project-euler",
"path": "/rust/src/p001.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn problem_001_2_test() {
assert_eq!(problem_001(1, 1000), 233168);
}
}<|fim_prefix|>// repo: treetips/project-euler path: /rust/src/p001.rs
/// # [Problem 1 「3と5の倍数」](http://odz.sakura.ne.jp/projecteuler/?Problem+1)
/// ## Description
/// ```txt
/// 10未満の自然数のうち, 3 もしくは 5 の倍数になっているものは 3... | code_fim | medium | {
"lang": "rust",
"repo": "treetips/project-euler",
"path": "/rust/src/p001.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_sign() {
let query = WechatQuery {
signature: "6db4861c77e0633e0105672fcd41c9fc2766e26e".to_owned(),
timestamp: "timestamp".to_owned(),
nonce: "nonce".to_owned(),
echostr: None,
};
assert!(!query.verify_sign("b... | code_fim | medium | {
"lang": "rust",
"repo": "gwy15/wechat-push-server-rs",
"path": "/src/routes/callback/verification.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gwy15/wechat-push-server-rs path: /src/routes/callback/verification.rs
use serde::Deserialize;
use std::time::SystemTime;
#[derive(Deserialize)]
pub struct WechatQuery {
signature: String,
timestamp: String,
nonce: String,
pub echostr: Option<String>,
}
impl WechatQuery {
f... | code_fim | hard | {
"lang": "rust",
"repo": "gwy15/wechat-push-server-rs",
"path": "/src/routes/callback/verification.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let query = WechatQuery {
signature: "6db4861c77e0633e0105672fcd41c9fc2766e26e".to_owned(),
timestamp: "timestamp".to_owned(),
nonce: "nonce".to_owned(),
echostr: None,
};
assert!(!query.verify_sign("bad_token"));
assert!(quer... | code_fim | medium | {
"lang": "rust",
"repo": "gwy15/wechat-push-server-rs",
"path": "/src/routes/callback/verification.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Err(MetacallLoaderError::FileNotFound(_)) =
loaders::from_single_file("random", inavlid_file)
{
// Everything Ok
} else {
panic!("Expected the loader fail with `FileNotFound` error variant!");
}
if let Err(MetacallLoaderError::FromFileFailure) =
... | code_fim | medium | {
"lang": "rust",
"repo": "metacall/core",
"path": "/source/ports/rs_port/tests/invalid_loaders_test.rs",
"mode": "spm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: metacall/core path: /source/ports/rs_port/tests/invalid_loaders_test.rs
use metacall::{loaders, switch, MetacallLoaderError};
use std::env;
#[test]
fn invalid_loaders() {
let _d = switch::initialize().unwrap();
<|fim_suffix|> if let Err(MetacallLoaderError::FromMemoryFailure) =
... | code_fim | hard | {
"lang": "rust",
"repo": "metacall/core",
"path": "/source/ports/rs_port/tests/invalid_loaders_test.rs",
"mode": "psm",
"license": "Python-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: scott-leung/scott-leung.github.io path: /src/rust-study/008-Flow of Control/match_test/destructuring/arrays_slices.rs
pub fn main() {
println!("------{} BEGIN------", file!());
// Try changing the values in the array, or make it a slice!
let array = [1, -2, 6];
match array {
... | code_fim | hard | {
"lang": "rust",
"repo": "scott-leung/scott-leung.github.io",
"path": "/src/rust-study/008-Flow of Control/match_test/destructuring/arrays_slices.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Combining these patterns, we can, for example, bind the first and
// last values, and store the rest of them in a single array
[first, middle @ .., last] => println!(
"array[0] = {}, middle = {:?}, array[2] = {}",
first, middle, last
),
}
... | code_fim | hard | {
"lang": "rust",
"repo": "scott-leung/scott-leung.github.io",
"path": "/src/rust-study/008-Flow of Control/match_test/destructuring/arrays_slices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Or store them in another array/slice (the type depends on
// that of the value that is being matched against)
[3, second, tail @ ..] => println!(
"array[0] = 3, array[1] = {} and the other elements were {:?}",
second, tail
),
// Combining... | code_fim | hard | {
"lang": "rust",
"repo": "scott-leung/scott-leung.github.io",
"path": "/src/rust-study/008-Flow of Control/match_test/destructuring/arrays_slices.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: riederm/adventOfRust path: /day01/a/src/main.rs
use std::fs::File;
use std::io::{self, BufRead};
fn main() {
const TARGET: i32 = 2020;
let file = File::open("data.txt").unwrap();
let lines = io::BufReader::new(file).lines();
let mut numbers: Vec<i32> = lines
.map(|line|... | code_fim | medium | {
"lang": "rust",
"repo": "riederm/adventOfRust",
"path": "/day01/a/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> numbers.sort();
let mut bottom = 0;
let mut mid = 1;
let mut top = numbers.len() - 1;
let mut current = numbers[bottom] + numbers[mid] + numbers[top];
while current != TARGET {
if current < TARGET {
if numbers[bottom+1] - numbers[bottom] < numbers[mid+1] - nu... | code_fim | medium | {
"lang": "rust",
"repo": "riederm/adventOfRust",
"path": "/day01/a/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Phraeyll/point-mass-ballistics path: /src/units.rs
use crate::Numeric;
pub use uom::si::{
acceleration, angle, angular_velocity, area, energy,
f64::{
Acceleration, Angle, AngularVelocity, Area, ArealMassDensity, Energy, Length, Mass,
MassDensity, MolarHeatCapacity, Molar... | code_fim | medium | {
"lang": "rust",
"repo": "Phraeyll/point-mass-ballistics",
"path": "/src/units.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! my_quantity {
($value:expr) => {
$crate::units::MyQuantity {
dimension: ::std::marker::PhantomData,
units: ::std::marker::PhantomData,
value: $value,
}
};
}
pub(crate) use my_quantity;
macro_rules! quantity {
($value:expr) => {
... | code_fim | medium | {
"lang": "rust",
"repo": "Phraeyll/point-mass-ballistics",
"path": "/src/units.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: adamgreig/stm32ral path: /src/stm32f4/stm32f410/mod.rs
//! stm32ral module for stm32f410
/// Number of priority bits implemented by the NVIC
pub const NVIC_PRIO_BITS: u8 = 4;
/// Interrupt-related magic for this device
pub mod interrupts;
pub use self::interrupts::Interrupt;
pub use self::inte... | code_fim | hard | {
"lang": "rust",
"repo": "adamgreig/stm32ral",
"path": "/src/stm32f4/stm32f410/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: maximbaz/advents-of-code path: /src/year2021/day02.rs
use super::super::*;
pub struct Task;
pub enum Command {
Down(i32),
Up(i32),
Forward(i32),
}
impl Solution for Task {
type Input = Vec<Command>;
type Output = i32;
fn parse_input(&self, input: String) -> Self::Inpu... | code_fim | hard | {
"lang": "rust",
"repo": "maximbaz/advents-of-code",
"path": "/src/year2021/day02.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_part2() {
assert_eq!(
900,
Task.part2(
Task.parse_input(
"
forward 5
down 5
forward 8
up 3
down 8
forward 2
"
.to_string()
)
)
);
}
}<... | code_fim | hard | {
"lang": "rust",
"repo": "maximbaz/advents-of-code",
"path": "/src/year2021/day02.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hedgar2017/dhcp path: /protocol/src/v4/options/mod.rs
//! DHCP options module.
mod message_type;
mod option_tag;
mod overload;
pub use self::{message_type::MessageType, option_tag::OptionTag, overload::Overload};
use std::net::Ipv4Addr;
/// DHCP options.
///
/// Implemented completely with `... | code_fim | hard | {
"lang": "rust",
"repo": "hedgar2017/dhcp",
"path": "/protocol/src/v4/options/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> /*
RFC 2132 (continuation)
*/
// Application and Service Parameters (RFC 2132 §8) (continuation)
pub nis_v3_domain_name: Option<String>,
pub nis_v3_servers: Option<Vec<Ipv4Addr>>,
pub server_name: Option<String>,
pub bootfile_name: Option<String>,
pub home_agent_address... | code_fim | hard | {
"lang": "rust",
"repo": "hedgar2017/dhcp",
"path": "/protocol/src/v4/options/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> CachePool(BTreeMap::new())
}
/// reset all cache content including cache from other DB_URLs
pub fn reset_all(&mut self) {
self.0.clear();
}
/// clear the cache on this DB_URL
pub fn clear(&mut self, db_url: &str) -> Option<Cache> {
self.0.remove(db_url)
... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/intel/src/cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.tables.is_some()
}
fn has_window_cache(&self) -> bool {
self.windows.is_some()
}
fn perform_table_caching(
&mut self,
em: &mut EntityManager,
) -> Result<(), IntelError> {
println!("----> ACTUAL TABLE CACHING");
let tables = em.get... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/intel/src/cache.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ivanceras/diwata path: /crates/intel/src/cache.rs
use crate::{
error::IntelError,
window::{
self,
Window,
},
};
use lazy_static::lazy_static;
use rustorm::{
EntityManager,
Table,
};
use std::{
collections::BTreeMap,
sync::{
Arc,
Mutex,
... | code_fim | hard | {
"lang": "rust",
"repo": "ivanceras/diwata",
"path": "/crates/intel/src/cache.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn handle(
&mut self,
_msg: GetRouteFragment,
_ctx: &mut Context<Self>,
) -> Addr<route_fragment::RouteFragment> {
match self.route_fragments.get(&_msg.id) {
Some(trip) => trip.clone(),
None => {
println!("Creating new route f... | code_fim | hard | {
"lang": "rust",
"repo": "marcmos/mpkflow",
"path": "/src/route_fragment_registry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Handler<GetRouteFragment> for RouteFragmentRegistry {
type Result = Addr<route_fragment::RouteFragment>;
fn handle(
&mut self,
_msg: GetRouteFragment,
_ctx: &mut Context<Self>,
) -> Addr<route_fragment::RouteFragment> {
match self.route_fragments.get(&_msg... | code_fim | hard | {
"lang": "rust",
"repo": "marcmos/mpkflow",
"path": "/src/route_fragment_registry.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: marcmos/mpkflow path: /src/route_fragment_registry.rs
use actix::prelude::*;
#[path = "route_fragment.rs"]
pub mod route_fragment;
use std::collections::HashMap;
#[derive(Default)]
pub struct RouteFragmentRegistry {
route_fragments: HashMap<String, Addr<route_fragment::RouteFragment>>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "marcmos/mpkflow",
"path": "/src/route_fragment_registry.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(from[0] <= to[0], "{} > {}", from[0], to[0]);
assert!(from[1] <= to[1], "{} > {}", from[1], to[1]);
}
// let on_count = lights.into_iter().filter(|x| *x).count();
// println!("{} lights are on", on_count);
let brightness = lights.into_iter().fold(0, |a,b| a + b);
... | code_fim | hard | {
"lang": "rust",
"repo": "Retsam/AdventOfCode",
"path": "/2015/Day6/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Retsam/AdventOfCode path: /2015/Day6/src/main.rs
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
use std::cmp::max;
const INPUT_FILE: &'static str = "input.txt";
#[derive(Debug)]
enum Command {
On,
Off,
Toggle
}
fn parse_line(line: &str) -> (Command, [usize; ... | code_fim | hard | {
"lang": "rust",
"repo": "Retsam/AdventOfCode",
"path": "/2015/Day6/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: feifeivv/zebra path: /zebra-state/src/tests/setup.rs
use std::sync::Arc;
use proptest::prelude::*;
use zebra_chain::{
block::{Block, Height},
parameters::{
Network::{self, *},
NetworkUpgrade,
},
serialization::ZcashDeserializeInto,
transaction::Transaction,
... | code_fim | hard | {
"lang": "rust",
"repo": "feifeivv/zebra",
"path": "/zebra-state/src/tests/setup.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (state, genesis)
}
/// Return a `Transaction::V4` with the coinbase data from `coinbase`.
///
/// Used to convert a coinbase transaction to a version that the non-finalized state will accept.
pub(crate) fn transaction_v4_from_coinbase(coinbase: &Transaction) -> Transaction {
assert!(
!coi... | code_fim | hard | {
"lang": "rust",
"repo": "feifeivv/zebra",
"path": "/zebra-state/src/tests/setup.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut bad = Bad(false);
let mut stream = Stream::new(&mut bad, &mut client);
let mut cx = Context::from_waker(noop_waker_ref());
let r = stream.complete_io(&mut cx);
assert_eq!(
r.map_err(|err| err.kind()),
Poll::Ready(Err(io::ErrorKind::U... | code_fim | hard | {
"lang": "rust",
"repo": "async-rs/async-tls",
"path": "/src/rusttls/test_stream.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: async-rs/async-tls path: /src/rusttls/test_stream.rs
use super::Stream;
use futures_executor::block_on;
use futures_io::{AsyncRead, AsyncWrite};
use futures_util::io::{AsyncReadExt, AsyncWriteExt};
use futures_util::task::{noop_waker_ref, Context};
use futures_util::{future, ready};
use rustls::... | code_fim | hard | {
"lang": "rust",
"repo": "async-rs/async-tls",
"path": "/src/rusttls/test_stream.rs",
"mode": "psm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(()) as io::Result<()>
};
block_on(fut)
}
fn make_pair() -> (ServerConnection, ClientConnection) {
const CERT: &str = include_str!("../../tests/end.cert");
const CHAIN: &str = include_str!("../../tests/end.chain");
const RSA: &str = include_str!("../../tests/end.rsa");
... | code_fim | hard | {
"lang": "rust",
"repo": "async-rs/async-tls",
"path": "/src/rusttls/test_stream.rs",
"mode": "spm",
"license": "LicenseRef-scancode-unknown-license-reference",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: getditto/safer_ffi path: /src/proc_macro/derives/dyn_trait/coercions.rs
//! Types which can be coerced to a `VirtualPtr<dyn Trait…>`.
use super::*;
#[allow(unused)]
macro_rules! quote {( $($tt:tt)* ) => (
quote_spanned! { Span::mixed_site()=>
$($tt)*
}
)}
pub
enum Coercible {
... | code_fim | hard | {
"lang": "rust",
"repo": "getditto/safer_ffi",
"path": "/src/proc_macro/derives/dyn_trait/coercions.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub
fn as_type (
self: &'_ Coercible,
e @ Env { ඞ, .. }: &Env<'_>,
) -> TokenStream2
{
let ty = match *self {
| Self::Box => {
squote!(
#ඞ::boxed::Box<#{ e.impl_Trait }>
)
},
| S... | code_fim | hard | {
"lang": "rust",
"repo": "getditto/safer_ffi",
"path": "/src/proc_macro/derives/dyn_trait/coercions.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: whtahy/exercism path: /rust/06 prime.rs
// Sieve of Erathosthenes
// Adapted from: https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
pub fn nth(n: u32) -> Option<u32> {
let n = n as usize;
if n == 0 {
None
} else if n <= 6 {
Some(sieve(100)[n - 1])
} else {
... | code_fim | medium | {
"lang": "rust",
"repo": "whtahy/exercism",
"path": "/rust/06 prime.rs",
"mode": "psm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let n = n as usize;
let l = (n as f64).sqrt().ceil() as usize;
let mut v = vec![true; n];
for i in 2..l {
if v[i] {
let mut j = i * i;
while j < n {
v[j] = false;
j += i;
}
}
}
let mut out = Vec:... | code_fim | medium | {
"lang": "rust",
"repo": "whtahy/exercism",
"path": "/rust/06 prime.rs",
"mode": "spm",
"license": "CC0-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> process::Command::cargo_bin("cobalt")
.unwrap()
.args(&["new", "--trace", "My New Special Page"])
.current_dir(project_root.path())
.assert()
.success();
project_root
.child("my-new-special-page.md")
.assert(predicate::path::exists());
p... | code_fim | hard | {
"lang": "rust",
"repo": "staaas/cobalt.rs",
"path": "/tests/cli.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: staaas/cobalt.rs path: /tests/cli.rs
extern crate assert_cmd;
extern crate assert_fs;
extern crate predicates;
use std::process;
use assert_cmd::prelude::*;
use assert_fs::prelude::*;
use predicates::prelude::*;
#[test]
pub fn invalid_calls() {
process::Command::cargo_bin("cobalt")
... | code_fim | hard | {
"lang": "rust",
"repo": "staaas/cobalt.rs",
"path": "/tests/cli.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DyrellC/bee-p path: /bee-common-ext/src/event.rs
// Copyright 2020 IOTA Stiftung
//
// 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://www.apache.org/licen... | code_fim | medium | {
"lang": "rust",
"repo": "DyrellC/bee-p",
"path": "/bee-common-ext/src/event.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let bus = Bus::default();
bus.add_listener(|_: &Foo| println!("Received a foo!"));
bus.dispatch(Foo);
}
#[test]
fn send_sync() {
fn helper<T: Send + Sync>() {}
helper::<Bus<'static>>();
}
// #[bench]
// fn bench_add_two(b: &mut Bencher) {... | code_fim | hard | {
"lang": "rust",
"repo": "DyrellC/bee-p",
"path": "/bee-common-ext/src/event.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tristan/tosho path: /src/database.rs
use crate::models::Quality;
use chrono::NaiveDateTime;
use rusqlite::{params, Connection, Error as RusqliteError, OptionalExtension, Result};
use std::env;
use std::path::PathBuf;
use wildmatch::WildMatch;
#[derive(Debug)]
pub enum Error {
DbError(Rusqli... | code_fim | hard | {
"lang": "rust",
"repo": "tristan/tosho",
"path": "/src/database.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn list_episodes_missing_nzb(
&self,
) -> Result<Vec<(i64, String, String, Option<Quality>, i32, i32)>, Error> {
let mut stmt = self.conn.prepare(
r#"SELECT e.show_id, s.name, s."group", s.quality, e.episode, e.version
FROM episodes e
J... | code_fim | hard | {
"lang": "rust",
"repo": "tristan/tosho",
"path": "/src/database.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let serialized = serde_yaml::to_string(&original).unwrap();
let deserialized = serde_yaml::from_str(&serialized).unwrap();
assert_eq!(original, deserialized);
// 3
let original = E::Mixed([0; 8], [5; 44], "asd".to_string());
let serialized = serde_yaml::to_string(&original).unwr... | code_fim | hard | {
"lang": "rust",
"repo": "uint/serbia",
"path": "/tests/01_basic_use.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uint/serbia path: /tests/01_basic_use.rs
use serbia::serbia;
use serde::{Deserialize, Serialize};
#[test]
fn regular_struct_roundtrip() {
#[serbia]
#[derive(Debug, Serialize, Deserialize, PartialEq)]
struct S {
arr_a: [u8; 300],
arr_b: [u8; 42],
arr_small: [u... | code_fim | hard | {
"lang": "rust",
"repo": "uint/serbia",
"path": "/tests/01_basic_use.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// The compiler produces a closure as part of this function. That closure initially takes an
// argument _task_context. Later, when the MIR for that closure is transformed into a generator
// state machine, _task_context is demoted to not be an argument, but just part of an unnamed
// argument. If we emit... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/task-context-arg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn poll_recv() {
// This box is necessary in order to reproduce the problem.
let _: Box<dyn Future<Output = ()>> = Box::new(recv_unit());
}<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/async-await/task-context-arg.rs
// Checks that we don't get conflicting arguments in our debug info ... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/task-context-arg.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rust path: /tests/ui/async-await/task-context-arg.rs
// Checks that we don't get conflicting arguments in our debug info with a particular async function
// structure.
<|fim_suffix|>#![crate_type = "lib"]
use std::future::Future;
// The compiler produces a closure as part of this fu... | code_fim | medium | {
"lang": "rust",
"repo": "rust-lang/rust",
"path": "/tests/ui/async-await/task-context-arg.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: thiolliere/fefe path: /src/entity/mod.rs
use itertools::Itertools;
use lyon::svg::path::default::Path;
use lyon::svg::path::iterator::PathIterator;
use lyon::svg::path::FlattenedEvent;
use lyon::tessellation::geometry_builder::simple_builder;
use lyon::tessellation::{FillOptions, FillTessellator... | code_fim | hard | {
"lang": "rust",
"repo": "thiolliere/fefe",
"path": "/src/entity/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
let mut vertex_builder = simple_builder(&mut buffers);
let mut tessellator = FillTessellator::new();
tessellator
.tessellate_path(
value.path_iter(),
&FillOptions::default().with_normals(false),
... | code_fim | hard | {
"lang": "rust",
"repo": "thiolliere/fefe",
"path": "/src/entity/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dtolnay-contrib/ockam path: /implementations/rust/ockam/ockam_examples/examples/step-4-server.rs
use ockam::{async_worker, Context, Result, Route, Routed, Worker};
use ockam_transport_tcp::{self as tcp, TcpRouter};
use std::net::SocketAddr;
struct EchoService;
const HUB_ADDRESS: &str = "127.0.... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/ockam",
"path": "/implementations/rust/ockam/ockam_examples/examples/step-4-server.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[ockam::node]
async fn main(ctx: Context) -> Result<()> {
let router = TcpRouter::register(&ctx).await?;
let hub_connection =
tcp::start_tcp_worker(&ctx, HUB_ADDRESS.parse::<SocketAddr>().unwrap()).await?;
router.register(&hub_connection).await?;
ctx.start_worker("echo_service",... | code_fim | hard | {
"lang": "rust",
"repo": "dtolnay-contrib/ockam",
"path": "/implementations/rust/ockam/ockam_examples/examples/step-4-server.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Prior99/rumble path: /src/message_types.rs
use crate::mumble;
use byteorder::{BigEndian, WriteBytesExt};
use protobuf::{CodedInputStream, Message, ProtobufResult};
/// An enum which contains all possible messages bundled together with it's content.
#[derive(Debug)]
pub enum MessageType {
Ve... | code_fim | hard | {
"lang": "rust",
"repo": "Prior99/rumble",
"path": "/src/message_types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut message = M::new();
M::merge_from(&mut message, &mut CodedInputStream::from_bytes(payload))?;
Ok(message)
}
/// Tries to interpret the supplied bytes as a message of type `id`.
pub fn from_raw(id: u16, payload: &[u8]) -> ProtobufResult<MessageType> {
us... | code_fim | hard | {
"lang": "rust",
"repo": "Prior99/rumble",
"path": "/src/message_types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> // texturing calculations
let tex_id = (WORLD[map_y as usize][map_x as usize] - 1) as usize;
// calculate value of wall_x
// where exactly the wall was hit
let mut wall_x: f64 = if side_hit {
self.pos.x + perp_wall_dist * ray_dir.x
} else {
self.pos.y +... | code_fim | hard | {
"lang": "rust",
"repo": "magnusjacobsen/shoota",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: magnusjacobsen/shoota path: /src/main.rs
use ggez;
use ggez::event::{self, EventHandler, KeyCode};
use ggez::graphics::{self, Image};
use ggez::{Context, GameResult, GameError, timer};
use ggez::conf::WindowMode;
use ggez::input::{mouse, keyboard};
use glam::*;
use std::path;
use std::env;
co... | code_fim | hard | {
"lang": "rust",
"repo": "magnusjacobsen/shoota",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Pos {
pub line: u32,
pub column: u32,
}
#[derive(Debug, Clone, PartialEq)]
pub struct TokenAndPos {
pub token: Token,
pub pos: Pos,
}
impl Pos {
pub fn new(line: u32, column: u32) -> Self {
Pos {
line: line,
... | code_fim | hard | {
"lang": "rust",
"repo": "hawnzug/gmachine",
"path": "/src/token.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: hawnzug/gmachine path: /src/token.rs
#[derive(Debug, Clone, PartialEq)]
pub enum Token {
Equal,
OpenParen,
CloseParen,
OpenBrace,
CloseBrace,
Semi,
Comma,
RightArrow,
BackSlash,
Dot,
<|fim_suffix|>#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Pos {
... | code_fim | hard | {
"lang": "rust",
"repo": "hawnzug/gmachine",
"path": "/src/token.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>macro_rules! impl_select_builder {
($(
$Tuple:tt {
$(($idx:tt) -> $T:ident, $ST: ident, $TT: ident,) +
}
)+) => {
$(
impl<Table, DB, $($T,)+> BuildSelect<
Table, DB, ($(<MaybeNull<$T> as Expression>::SqlType,)+ ),
> fo... | code_fim | hard | {
"lang": "rust",
"repo": "p-alik/wundergraph",
"path": "/wundergraph/src/query_builder/selection/select.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: p-alik/wundergraph path: /wundergraph/src/query_builder/selection/select.rs
use crate::diesel_ext::MaybeNull;
use crate::error::Result;
use crate::scalar::WundergraphScalarValue;
use diesel::backend::Backend;
use diesel::expression::NonAggregate;
use diesel::query_builder::QueryFragment;
use die... | code_fim | hard | {
"lang": "rust",
"repo": "p-alik/wundergraph",
"path": "/wundergraph/src/query_builder/selection/select.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> select: &LookAheadSelection<'_, WundergraphScalarValue>,
get_field_name: impl Fn(usize) -> &'static str,
is_primary_key_index: impl Fn(usize) -> bool,
should_select_primary_key: bool,
) -> Result<
... | code_fim | hard | {
"lang": "rust",
"repo": "p-alik/wundergraph",
"path": "/wundergraph/src/query_builder/selection/select.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn test_zlib_with_header_78() {
if let Ok(r) = ZlibWithHeader78::from_file("src/zlib_with_header_78.bin") {
assert_eq!(r.data, vec!([0x61, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f, 0x7... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/tests/test_zlib_with_header_78.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Ok(r) = ZlibWithHeader78::from_file("src/zlib_with_header_78.bin") {
assert_eq!(r.data, vec!([0x61, 0x20, 0x71, 0x75, 0x69, 0x63, 0x6b, 0x20, 0x62, 0x72, 0x6f, 0x77, 0x6e, 0x20, 0x66, 0x6f, 0x78, 0x20, 0x6a, 0x75, 0x6d, 0x70, 0x73, 0x20, 0x6f, 0x76, 0x65, 0x72]));
}
}<|fim_prefix|>/... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/tests/test_zlib_with_header_78.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaitai-io/kaitai_struct_tests path: /spec/rust/tests/test_zlib_with_header_78.rs
// Autogenerated from KST: please remove this line if doing any edits by hand!
<|fim_suffix|>#[test]
fn test_zlib_with_header_78() {
if let Ok(r) = ZlibWithHeader78::from_file("src/zlib_with_header_78.bin") {
... | code_fim | medium | {
"lang": "rust",
"repo": "kaitai-io/kaitai_struct_tests",
"path": "/spec/rust/tests/test_zlib_with_header_78.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> <$t>::cast_from(other.handle_ref())?.ok_or_else(|| crate::errors::Error::rust_error("Type mismatch"))
}
}
};
($t: ty, $t2: ty, $($ts:ty),+) => {
try_from!($t, $t2);
try_from!($t, $($ts),*);
}
}
try_from!(Buffer, Handle);
try_from!(Generator, Handle);
t... | code_fim | hard | {
"lang": "rust",
"repo": "ndarilek/synthizer-rs",
"path": "/synthizer/src/casting.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ndarilek/synthizer-rs path: /synthizer/src/casting.rs
//! Implement casting (upcasting and downcasting) for Synthizer objects. Allows
//! converting any object to a handle, and upcasting/downcasting along the
//! inheritance hierarchy.
use crate::handle::*;
use crate::*;
/// Set up the list of ... | code_fim | hard | {
"lang": "rust",
"repo": "ndarilek/synthizer-rs",
"path": "/synthizer/src/casting.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.