text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_suffix|>where
I: Stream<Item = char>,
I::Error: ParseError<I::Item, I::Range, I::Position>,
{
many1(alpha_num()).map(|s| {
if s == BLANK {
Term::Symbol(Sym::Blank)
} else if s == ANY {
Term::Symbol(Sym::Any)
} else {
Term::Symbol(Sym::String(... | code_fim | hard | {
"lang": "rust",
"repo": "heyrutvik/turing-script-rs",
"path": "/src/parser.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match *self {
CreationError::CreationFailed => "Creation Failed",
CreationError::DuplicateInstances => "Only one instance of Magic may exist at a time",
CreationError::MagicError(_) => "libmagic error",
}
}
}
#[cfg(test)]
mod tests {
use super::... | code_fim | hard | {
"lang": "rust",
"repo": "sunsided/rust-ffi-experiments",
"path": "/magic/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if mimetype.is_null() {
Err(self.last_error().unwrap_or_default())
} else {
let mimetype = unsafe { CStr::from_ptr(mimetype) };
Ok(mimetype.to_string_lossy().to_string())
}
}
/// Get the most recent `libmagic` error message, if there is ... | code_fim | hard | {
"lang": "rust",
"repo": "sunsided/rust-ffi-experiments",
"path": "/magic/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: sunsided/rust-ffi-experiments path: /magic/src/lib.rs
//! An interface to `libmagic`, a tool for file type recognition.
//!
//! # Examples
//!
//! You'll typically interact with `libmagic` by creating a `Magic` object and
//! using that to query a file's type.
//!
//! ```rust
//! # extern crate ... | code_fim | hard | {
"lang": "rust",
"repo": "sunsided/rust-ffi-experiments",
"path": "/magic/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/code_of_rust_by_example/src/types/aliasing.rs
type NanoSecond = u64;
type Inch = u64;
#[allow(non_camel_case_types)]
type u64_t = u64;
#[test]
fn test_aliasing() {
<|fim_suffix|> println!(
"{} nanoseconds + {} inches = {} units... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/code_of_rust_by_example/src/types/aliasing.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!(
"{} nanoseconds + {} inches = {} units? ",
nanoseconds,
inches,
nanoseconds + inches
);
}<|fim_prefix|>// repo: rcore-os-infohub/ossoc2020-VitalyAnkh-daily path: /Rust/code_of_rust_by_example/src/types/aliasing.rs
type NanoSecond = u64;
type Inch = u64;
... | code_fim | medium | {
"lang": "rust",
"repo": "rcore-os-infohub/ossoc2020-VitalyAnkh-daily",
"path": "/Rust/code_of_rust_by_example/src/types/aliasing.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn partial_rsweep<T: MultiSweep<Point3, Curve, Surface>>(
elem: &T,
origin: Point3,
axis: Vector3,
angle: Rad<f64>,
) -> T::Swept {
let division = if angle.0.abs() < PI.0 { 1 } else { 2 };
let mat0 = Matrix4::from_translation(-origin.to_vec());
let mat1 = Matrix4::from_axis_ang... | code_fim | hard | {
"lang": "rust",
"repo": "khachaturh/truck",
"path": "/truck-modeling/src/builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Sweeps a vertex, an edge, a wire, a face, or a shell by the rotation.
/// # Details
/// If the absolute value of `angle` is more than 2π rad, then the result is closed shape.
/// For example, the result of sweeping a disk is a bent cylinder if `angle` is less than 2π rad
/// and a solid torus if `angl... | code_fim | hard | {
"lang": "rust",
"repo": "khachaturh/truck",
"path": "/truck-modeling/src/builder.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: khachaturh/truck path: /truck-modeling/src/builder.rs
);
/// ```
#[inline(always)]
pub fn cone<R: Into<Rad<f64>>>(wire: &Wire, axis: Vector3, angle: R) -> Shell {
let angle = angle.into();
let closed = angle.0.abs() >= 2.0 * PI.0;
let mut wire = wire.clone();
if wire.is_empty() {... | code_fim | hard | {
"lang": "rust",
"repo": "khachaturh/truck",
"path": "/truck-modeling/src/builder.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jn7163/zoxide path: /src/db.rs
use crate::config::get_zo_maxage;
use crate::dir::Dir;
use crate::error::AppError;
use crate::types::{Rank, Timestamp};
use failure::ResultExt;
use fs2::FileExt;
use serde::{Deserialize, Serialize};
use std::fs::File;
use std::io::{self, BufReader, BufWriter};
use ... | code_fim | hard | {
"lang": "rust",
"repo": "jn7163/zoxide",
"path": "/src/db.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.dirs.retain(|dir| dir.rank >= 1.0);
self.modified = true;
Ok(())
}
pub fn query(&mut self, keywords: &[String], now: Timestamp) -> Option<Dir> {
// TODO: expand "~" in queries
loop {
let (idx, dir) = self
.dirs
... | code_fim | hard | {
"lang": "rust",
"repo": "jn7163/zoxide",
"path": "/src/db.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn surrounding(a: AABB, b: AABB) -> AABB {
let small = Vector::new(utils::fast_min(a.min.x, b.min.x), utils::fast_min(a.min.y, b.min.y), utils::fast_min(a.min.z, b.min.z));
let big = Vector::new(utils::fast_max(a.max.x, b.max.x), utils::fast_max(a.max.y, b.max.y), utils::fast_max(a... | code_fim | hard | {
"lang": "rust",
"repo": "paulcacheux/raytracer",
"path": "/src/hitable/aabb.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paulcacheux/raytracer path: /src/hitable/aabb.rs
use crate::prelude::*;
#[derive(Debug, Clone, Copy)]
pub struct AABB {
pub min: Vector,
pub max: Vector,
}
impl AABB {
pub fn new(min: Vector, max: Vector) -> Self {
AABB { min, max }
}
pub fn hit(self, ray: Ray, tmi... | code_fim | medium | {
"lang": "rust",
"repo": "paulcacheux/raytracer",
"path": "/src/hitable/aabb.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: kaj/rsass path: /rsass/tests/spec/libsass/keyframes.rs
//! Tests auto-converted from "sass-spec/spec/libsass/keyframes.hrx"
#[allow(unused)]
fn runner() -> crate::TestRunner {
super::runner().with_cwd("keyframes")
}
#[test]
fn test() {
assert_eq!(
runner().ok("div {\
... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/libsass/keyframes.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> @content;\
\n}\n\
\nfoo {\
\n @include fudge() {\
\n div {\
\n color: red;\
\n }\
\n }\
\n}\n"),
"div {\
\n color: #181818;\
\n}\
\n@-webkit-keyframes ... | code_fim | hard | {
"lang": "rust",
"repo": "kaj/rsass",
"path": "/rsass/tests/spec/libsass/keyframes.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn make_multi_sig(n: usize, msg_size: usize) -> (Vec<PublicKey>, Vec<Signature>, Vec<u8>) {
let mut pubs: Vec<PublicKey> = Vec::new();
let mut sigs: Vec<Signature> = Vec::new();
let mut msgs: Vec<u8> = Vec::new();
msgs.resize_with(n * msg_size, Default::default);
for i in 0..n {
... | code_fim | hard | {
"lang": "rust",
"repo": "herumi/bls-eth-rust",
"path": "/tests/test.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: herumi/bls-eth-rust path: /tests/test.rs
use bls_eth_rust::*;
use hex;
use std::fs::File;
use std::io::BufRead;
use std::io::BufReader;
use std::mem;
fn secretkey_deserialize_hex_str(x: &str) -> SecretKey {
SecretKey::from_serialized(&hex::decode(x).unwrap()).unwrap()
}
#[allow(dead_code)]... | code_fim | hard | {
"lang": "rust",
"repo": "herumi/bls-eth-rust",
"path": "/tests/test.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: uasi/decone path: /src/agile_keychain/attachment.rs
use serde_json;
use std::fs;
use std::io::{self, Result as IoResult};
use std::path::{Path, PathBuf};
const FILES_DIR_REL_PATH: &'static str = "a/default/files";
#[derive(Clone, Debug)]
pub struct Archive {
entries: Vec<ArchiveEntry>,
}
... | code_fim | hard | {
"lang": "rust",
"repo": "uasi/decone",
"path": "/src/agile_keychain/attachment.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> })
}
}
trait JsonValueExt {
fn as_owned_string(&self) -> Option<String>;
fn retrieve<T, F>(&self, key: &str, mapper: F) -> IoResult<T>
where F: FnOnce(&serde_json::Value) -> Option<T>;
}
impl JsonValueExt for serde_json::Value {
fn as_owned_string(&self) -> Option<String>... | code_fim | hard | {
"lang": "rust",
"repo": "uasi/decone",
"path": "/src/agile_keychain/attachment.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl JsonValueExt for serde_json::Value {
fn as_owned_string(&self) -> Option<String> {
self.as_string().and_then(|s| Some(s.to_string()))
}
fn retrieve<T, F>(&self, key: &str, mapper: F) -> IoResult<T>
where F: FnOnce(&serde_json::Value) -> Option<T>
{
self
... | code_fim | hard | {
"lang": "rust",
"repo": "uasi/decone",
"path": "/src/agile_keychain/attachment.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: theHazzard/rust_uno_core path: /src/game.rs
mod deck;
mod player;
pub use deck::*;
pub use player::*;
#[derive(Debug)]
pub enum Direction {
Forward,
Backward,
}
#[derive(Debug)]
pub struct Game {
pub deck: Deck,
pub played: Vec<Card>,
pub players: Vec<Player>,
pub turn: u8,
p... | code_fim | hard | {
"lang": "rust",
"repo": "theHazzard/rust_uno_core",
"path": "/src/game.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn get_next_player(&self, playerNumber: u8) -> u8 {
match self.direction {
Direction::Forward => {
if playerNumber == self.players.len() as u8 {
0
} else {
playerNumber + 1
}
},
Direction::Backward => {
if playerNumber == 0 {
... | code_fim | hard | {
"lang": "rust",
"repo": "theHazzard/rust_uno_core",
"path": "/src/game.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> t
},
|t| t.get("object"),
BatchSize::SmallInput,
)
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches);<|fim_prefix|>// repo: 0xABAD/pddl-rs path: /benches/types.rs
use criterion::{criterion_group, criterion_main,... | code_fim | hard | {
"lang": "rust",
"repo": "0xABAD/pddl-rs",
"path": "/benches/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0xABAD/pddl-rs path: /benches/types.rs
use criterion::{criterion_group, criterion_main, BatchSize, Criterion};
use pddl_rs::pddl::types::Types;
<|fim_suffix|> t
},
|t| t.get("object"),
BatchSize::SmallInput,
)
});
}
criterion_group... | code_fim | hard | {
"lang": "rust",
"repo": "0xABAD/pddl-rs",
"path": "/benches/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> tpdu::send(ca, slot_id, tpdu::TT_DATA_LAST, &response)
}
fn handle_create_session_response(ca: &mut CaDevice, _slot_id: u8, spdu: &[u8]) -> Result<()> {
assert_size(spdu, 9)?;
let session_id = u16::from_be_bytes(spdu[7 ..= 8].try_into().unwrap());
if spdu[2] == SS_OK {
apdu::op... | code_fim | hard | {
"lang": "rust",
"repo": "cesbo/libdvb",
"path": "/src/ca/spdu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> match spdu[0] {
ST_SESSION_NUMBER => {
handle_session_number(ca, slot_id, spdu)
.context("ST_SESSION_NUMBER failed")
}
ST_OPEN_SESSION_REQUEST => {
handle_open_session_request(ca, slot_id, spdu)
.context("ST_OPEN_SESSION_R... | code_fim | hard | {
"lang": "rust",
"repo": "cesbo/libdvb",
"path": "/src/ca/spdu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cesbo/libdvb path: /src/ca/spdu.rs
//! Session Protocol Data Unit
//!
//! en50221 7.2.4
//! The session layer uses a Session Protocol Data Unit (SPDU) structure
//! to exchange data at session level either from the host to the module
//! or from the module to the host.
use {
std::convert::... | code_fim | hard | {
"lang": "rust",
"repo": "cesbo/libdvb",
"path": "/src/ca/spdu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>// match utils::download_file("http://developer.highstreetvouchers.com/images/logo.png", "download"){
// DownloadFileError::Io(err) => println!("Io error {}", err),
// DownloadFileError::Network(err) => println!("Network error {}", err),
// DownloadFileError::None => {},
// }
pub fn download_i... | code_fim | medium | {
"lang": "rust",
"repo": "jersey26/manga-downloader",
"path": "/src/utils/file_download.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jersey26/manga-downloader path: /src/utils/file_download.rs
use std::io;
use std::io::Error as IoError;
use std::path::Path;
use std::fs::File;
use hyper::error::Error as HyperError;
use hyper::Client;
use hyper::header::Connection;
use hyper::header::ContentType;
pub enum DownloadFileError {
... | code_fim | hard | {
"lang": "rust",
"repo": "jersey26/manga-downloader",
"path": "/src/utils/file_download.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: julien-montmartin/ternary-tree path: /src/lib.rs
mut prefix_tail = key_prefix.chars();
match prefix_tail.next() {
None => visit_values_r(&self.root, &mut callback),
Some(label) => {
let new_root = find_complete_root_r(&self.root, label, prefix_... | code_fim | hard | {
"lang": "rust",
"repo": "julien-montmartin/ternary-tree",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> pretty_print_r(&self.root, &mut ids, writer);
let _ = writeln!(writer, "}}");
}
/// Create a [double-ended]( http://doc.rust-lang.org/std/iter/trait.DoubleEndedIterator.html) iterator which
/// successively returns all values of the tree. Values are immutable, and are found ... | code_fim | hard | {
"lang": "rust",
"repo": "julien-montmartin/ternary-tree",
"path": "/src/lib.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: julien-montmartin/ternary-tree path: /src/lib.rs
_root, &mut callback)
}
}
}
/// Recursively walks the tree and calls `callback` closure on each immutable value whose key is _close_ to
/// `key`. A key is considered _close_ to `key` within a [Hamming distance](
... | code_fim | hard | {
"lang": "rust",
"repo": "julien-montmartin/ternary-tree",
"path": "/src/lib.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: nmaraston/reproto path: /lib/backend/src/lib.rs
extern crate genco;
extern crate linked_hash_map;
#[macro_use]
extern crate log;
extern crate reproto_core as core;
extern crate reproto_parser as parser;
extern crate reproto_path_parser as path_parser;
#[cfg(feature = "repository")]
extern crate ... | code_fim | hard | {
"lang": "rust",
"repo": "nmaraston/reproto",
"path": "/lib/backend/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn test_simple_sstable() {
let mut buffer = vec![];
{
let mut sstable_writer = VoidSSTable::writer(&mut buffer);
assert!(sstable_writer.write(&[17u8], &()).is_ok());
assert!(sstable_writer.write(&[17u8, 18u8, 19u8], &()).is_ok());
... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/src/termdict/sstable_termdict/sstable/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: windoze/tantivy path: /src/termdict/sstable_termdict/sstable/mod.rs
use std::io::{self, Write};
use std::usize;
use merge::ValueMerger;
mod delta;
pub mod merge;
pub mod value;
pub(crate) mod sstable_index;
pub(crate) use self::sstable_index::{SSTableIndex, SSTableIndexBuilder};
pub(crate) m... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/src/termdict/sstable_termdict/sstable/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert_eq!(
common_prefix_len(left.as_bytes(), right.as_bytes()),
expect_len
);
assert_eq!(
common_prefix_len(right.as_bytes(), left.as_bytes()),
expect_len
);
}
#[test]
fn test_common_prefix_len() {
aux_t... | code_fim | hard | {
"lang": "rust",
"repo": "windoze/tantivy",
"path": "/src/termdict/sstable_termdict/sstable/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: JosephLenton/clubhouse-api path: /src/get/stories.rs
pub mod story_public_id;
pub use self::story_public_id::ClubhouseGetStoryStoryPublicId;
<|fim_suffix|>impl ClubhouseGetStory {
pub fn story_public_id(
self,
story_public_id: u64,
) -> self::story_public_id::ClubhouseGe... | code_fim | medium | {
"lang": "rust",
"repo": "JosephLenton/clubhouse-api",
"path": "/src/get/stories.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl ClubhouseGetStory {
pub fn story_public_id(
self,
story_public_id: u64,
) -> self::story_public_id::ClubhouseGetStoryStoryPublicId {
self::story_public_id::ClubhouseGetStoryStoryPublicId {
path: self.path.push(&story_public_id),
}
}
}<|fim_prefi... | code_fim | medium | {
"lang": "rust",
"repo": "JosephLenton/clubhouse-api",
"path": "/src/get/stories.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> ExperimentStatus::Idle {
since: Utc::now(),
}
}
}<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/system/modules/experiment/status.rs
use std::sync::Arc;
use chrono::{DateTime, Utc};
use lib_interop::models::{DEvent, DReport, DRunnerId};
<|fim_middle|>#[d... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/system/modules/experiment/status.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Patryk27/cr8r path: /apps/controller/src/system/modules/experiment/status.rs
use std::sync::Arc;
use chrono::{DateTime, Utc};
use lib_interop::models::{DEvent, DReport, DRunnerId};
<|fim_suffix|> ExperimentStatus::Idle {
since: Utc::now(),
}
}
}<|fim_middle|>#[d... | code_fim | hard | {
"lang": "rust",
"repo": "Patryk27/cr8r",
"path": "/apps/controller/src/system/modules/experiment/status.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn bundle_installer<PB, C>(
builder: &mut AppBuilder<PB>,
channel: C,
) -> Result<(), PipelineBuilderError>
where
PB: PipelineBuilder,
C: SimpChannel + Send + Sync + 'static,
{
#[cfg(debug_assertions)]
builder.install_resource(HaRendererDebuggerSystemCache::new(channel));
... | code_fim | hard | {
"lang": "rust",
"repo": "PsichiX/Oxygengine",
"path": "/engine/ha-renderer-debugger/src/lib.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: PsichiX/Oxygengine path: /engine/ha-renderer-debugger/src/lib.rs
extern crate oxygengine_core as core;
extern crate oxygengine_editor_tools as editor;
extern crate oxygengine_ha_renderer as renderer;
pub mod request;
pub mod system;
<|fim_suffix|>pub fn bundle_installer<PB, C>(
builder: &m... | code_fim | hard | {
"lang": "rust",
"repo": "PsichiX/Oxygengine",
"path": "/engine/ha-renderer-debugger/src/lib.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjhopman/starlark-rust path: /starlark/src/values/function.rs
elf {
FunctionArg::ArgsArray(v) => v.into_args_array(),
_ => Err(ValueError::IncorrectParameterType),
}
}
pub fn into_kw_args_dict<T: TryParamConvertFromValue>(
self,
param_name... | code_fim | hard | {
"lang": "rust",
"repo": "cjhopman/starlark-rust",
"path": "/starlark/src/values/function.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cjhopman/starlark-rust path: /starlark/src/values/function.rs
res.push(T::try_from(v).map_err(|_| ValueError::IncorrectParameterTypeNamed(""))?);
}
} else {
skip = self.index - self.positional.len();
}
if let Some(ref args) = self.args.take() {
... | code_fim | hard | {
"lang": "rust",
"repo": "cjhopman/starlark-rust",
"path": "/starlark/src/values/function.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl From<ArgsArray> for Value {
fn from(a: ArgsArray) -> Value {
let mut v = Value::new(a);
v.freeze();
v.shared()
}
}
#[derive(Debug)]
pub struct KwargsData {}
pub struct KwargsIter {
data: Rc<KwargsData>,
pos: usize,
}
/*
impl Iterator<Item=Value> for KwargsIt... | code_fim | hard | {
"lang": "rust",
"repo": "cjhopman/starlark-rust",
"path": "/starlark/src/values/function.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: TechnoTone/AdventOfCode2019_Rust path: /src/day1.rs
use std::str::FromStr;
#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<i32> {
input
.lines()
.map(|l| FromStr::from_str(l).unwrap())
.collect()
}
fn fuel_for(mass: &i32) -> i32 {
<|fim_... | code_fim | hard | {
"lang": "rust",
"repo": "TechnoTone/AdventOfCode2019_Rust",
"path": "/src/day1.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[aoc(day1, part2)]
pub fn part2(input: &[i32]) -> i32 {
return input.iter().map(real_fuel_for).sum();
}<|fim_prefix|>// repo: TechnoTone/AdventOfCode2019_Rust path: /src/day1.rs
use std::str::FromStr;
#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<i32> {
input
... | code_fim | hard | {
"lang": "rust",
"repo": "TechnoTone/AdventOfCode2019_Rust",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let mut total: i32 = 0;
let mut fuel: i32 = fuel_for(mass);
while fuel > 0 {
total += fuel;
fuel = fuel_for(&fuel);
}
return total;
}
#[aoc(day1, part1)]
pub fn part1(input: &[i32]) -> i32 {
return input.iter().map(fuel_for).sum();
}
#[aoc(day1, part... | code_fim | medium | {
"lang": "rust",
"repo": "TechnoTone/AdventOfCode2019_Rust",
"path": "/src/day1.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SPERAXIO/ckb path: /network/src/config.rs
use crate::{
errors::{ConfigError, Error},
PeerId, DEFAULT_SEND_BUFFER,
};
use ckb_logger::info;
use p2p::{
multiaddr::{Multiaddr, Protocol},
secio,
};
use rand;
use rand::Rng;
use serde::{Deserialize, Serialize};
use std::fs;
use std::io... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/network/src/config.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn whitelist_peers(&self) -> Result<Vec<(PeerId, Multiaddr)>, Error> {
let mut peers = Vec::with_capacity(self.whitelist_peers.len());
for addr_str in &self.whitelist_peers {
let mut addr = addr_str.to_owned();
let peer_id = match addr.pop() {
... | code_fim | hard | {
"lang": "rust",
"repo": "SPERAXIO/ckb",
"path": "/network/src/config.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rodrigocfd/winsafe path: /src/user/ffi.rs
use crate::kernel::ffi_types::*;
extern_sys! { "comdlg32";
ChooseColorW(PVOID) -> BOOL
CommDlgExtendedError() -> u32
}
#[cfg(target_pointer_width = "32")]
extern_sys! { "user32";
GetWindowLongW(HANDLE, i32) -> isize
SetWindowLongW(HANDLE,... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigocfd/winsafe",
"path": "/src/user/ffi.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>opWindow(HANDLE) -> HANDLE
GetUpdateRect(HANDLE, PVOID, BOOL) -> BOOL
GetUpdateRgn(HANDLE, HANDLE, BOOL) -> i32
GetWindow(HANDLE, u32) -> HANDLE
GetWindowDC(HANDLE) -> HANDLE
GetWindowDisplayAffinity(HANDLE, PVOID) -> BOOL
GetWindowInfo(HANDLE, PVOID) -> BOOL
GetWindowModuleFileNameW(HANDLE,... | code_fim | hard | {
"lang": "rust",
"repo": "rodrigocfd/winsafe",
"path": "/src/user/ffi.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub struct PageConfig {
pub page_size: usize,
pub page_num: usize,
}<|fim_prefix|>// repo: libellis/survey-manager path: /survey-manager-core/src/app_services/queries/authors_surveys_query.rs
use domain_patterns::query::Query;
<|fim_middle|>#[derive(Query)]
pub struct FindSurveysByAuthorQuery {
... | code_fim | medium | {
"lang": "rust",
"repo": "libellis/survey-manager",
"path": "/survey-manager-core/src/app_services/queries/authors_surveys_query.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: libellis/survey-manager path: /survey-manager-core/src/app_services/queries/authors_surveys_query.rs
use domain_patterns::query::Query;
<|fim_suffix|>pub struct PageConfig {
pub page_size: usize,
pub page_num: usize,
}<|fim_middle|>#[derive(Query)]
pub struct FindSurveysByAuthorQuery {
... | code_fim | medium | {
"lang": "rust",
"repo": "libellis/survey-manager",
"path": "/survey-manager-core/src/app_services/queries/authors_surveys_query.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let test_num = sample_space.sample(&mut rng);
//excludes numbers already tried
if !tested_numbers.contains(&test_num){
//run a single miller rabin test
let test_result = miller_rabin_witness(n, odd_component, power2, test_num);
if test_result {
return true
} else {
tested_number... | code_fim | hard | {
"lang": "rust",
"repo": "VanLeeuwarden/prob_prime",
"path": "/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: VanLeeuwarden/prob_prime path: /src/lib.rs
use std::u64;
use std::cmp::min;
extern crate rand;
use rand::distributions::{Distribution, Uniform};
extern crate modular_arithmetic;
use modular_arithmetic::{mut_even_power, split_odd_even, jacobi_symbol};
mod pseudoprime;
use pseudoprime::{miller... | code_fim | hard | {
"lang": "rust",
"repo": "VanLeeuwarden/prob_prime",
"path": "/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[derive(Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
pub struct RetryInfo {
pub enqueued_at: f64,
pub error_class: String,
pub error_message: String,
pub failed_at: f64,
pub retried_at: f64,
pub retry_count: u8
}<|fim_prefix|>// repo: daxhuiberts/sidecliq path: /... | code_fim | hard | {
"lang": "rust",
"repo": "daxhuiberts/sidecliq",
"path": "/sidemon-lib/src/types.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: daxhuiberts/sidecliq path: /sidemon-lib/src/types.rs
pub use serde_json::Value as JsonValue;
use serde::{Deserialize, Serialize};
use std::error::Error;
pub type Result<T> = std::result::Result<T, Box<dyn Error>>;
#[derive(Debug, Default, Deserialize, Serialize)]
#[serde(deny_unknown_fields)]
... | code_fim | hard | {
"lang": "rust",
"repo": "daxhuiberts/sidecliq",
"path": "/sidemon-lib/src/types.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>const INSTRUCTION_SIZE: u16 = 2;
impl RegisterBank {
pub fn new() -> RegisterBank {
let registers = [0; 32];
let program_counter = 0;
let flags = Flags{carry: false};
RegisterBank {registers, program_counter, flags}
}
pub fn increment_pc(&mut self) {
s... | code_fim | medium | {
"lang": "rust",
"repo": "mlafroce/avr-avogadro",
"path": "/src/core/register_bank.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn increment_pc(&mut self) {
self.program_counter += INSTRUCTION_SIZE;
}
pub fn set_carry(&mut self, carry: bool) {
self.flags.carry = carry;
}
pub fn get_carry(&self) -> bool {
self.flags.carry
}
}<|fim_prefix|>// repo: mlafroce/avr-avogadro path: /s... | code_fim | hard | {
"lang": "rust",
"repo": "mlafroce/avr-avogadro",
"path": "/src/core/register_bank.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: mlafroce/avr-avogadro path: /src/core/register_bank.rs
///# RegisterBank
///
/// MCU's general purpouse and specific registers
struct Flags {
carry: bool,
}
pub struct RegisterBank {
pub registers: [u8; 32],
pub program_counter: u16,
flags: Flags
}
const INSTRUCTION_SIZE: u16 ... | code_fim | hard | {
"lang": "rust",
"repo": "mlafroce/avr-avogadro",
"path": "/src/core/register_bank.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: yancouto/functional path: /src/gamestates/level_creator/level_config.rs
use serde::{Deserialize, Serialize};
use crate::prelude::*;
#[derive(Debug, Serialize, Deserialize)]
/// UserLevelConfig is the format in which the JSON level config file must be specified.
/// See the field descriptions b... | code_fim | hard | {
"lang": "rust",
"repo": "yancouto/functional",
"path": "/src/gamestates/level_creator/level_config.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>user's solution to the problem.
/// - The second is the reduction when the first function is applied to the user's solution.
///
/// Example for the level "boolean or":
/// `[["f: f TRUE FALSE A B", "A"], ["f: FALSE FALSE A B", "B"]]`
///
/// You must specify at least one test case... | code_fim | hard | {
"lang": "rust",
"repo": "yancouto/functional",
"path": "/src/gamestates/level_creator/level_config.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|>]`
pub solutions: Vec1<String>,
#[serde(default)]
/// You may optionally specify wrong solutions, and validation will make sure they do not
/// pass all tests.
pub wrong_solutions: Vec<String>,
#[serde(default)]
/// This is an optional list of additional constants the pla... | code_fim | hard | {
"lang": "rust",
"repo": "yancouto/functional",
"path": "/src/gamestates/level_creator/level_config.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Итерировать по строкам можно по-разному. По каждому символу(Unicode scalar value) можно
// пройтись c помощью такого цикла:
for c in "мука".chars() {
println!("{}", c);
}
// С помощью chars нельзя пройтись по так называемым кластерам графемов(grapheme clusters), из
// ко... | code_fim | hard | {
"lang": "rust",
"repo": "source-farm/Rust",
"path": "/8.2 - Строки/strings/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> // Также строки можно объединять с помощью макроса format!, который возвращает String:
let s1 = String::from("tic");
let s2 = String::from("tac");
let s3 = String::from("toe");
let s = format!("{}-{}-{}", s1, s2, s3);
println!("s: {}", s);
// Во многих языка программирования к... | code_fim | hard | {
"lang": "rust",
"repo": "source-farm/Rust",
"path": "/8.2 - Строки/strings/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: source-farm/Rust path: /8.2 - Строки/strings/src/main.rs
#![allow(unused_variables)]
fn main() {
// Когда в Rust говорят о строках, то имеются в виду два типа строк:
//
// - определённый в стандартной библиотеке тип String, который может расти в размере и т.д.
// - строко... | code_fim | hard | {
"lang": "rust",
"repo": "source-farm/Rust",
"path": "/8.2 - Строки/strings/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: alexmarchant/simple-c-compiler-in-rust path: /src/generator/expression.rs
use asm::Asm;
use generator;
use generator::term;
use parser::StackFrame;
use asm::Register::{Rax, Rcx, Al, Rbp};
use asm::RegisterOffset;
use parser::expression::{
Expression,
LogicalOrExpression,
LogicalOrOpe... | code_fim | hard | {
"lang": "rust",
"repo": "alexmarchant/simple-c-compiler-in-rust",
"path": "/src/generator/expression.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match binary_expression.operator {
EqualityOperator::Equal => {
asm.sete(&Al);
},
EqualityOperator::NotEqual => {
asm.setne(&Al);
},
}
}
}
fn relational_asm(asm: &mut Asm, expression: RelationalExpression,... | code_fim | hard | {
"lang": "rust",
"repo": "alexmarchant/simple-c-compiler-in-rust",
"path": "/src/generator/expression.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> if let Some(lang) = items.next() {
for item in items {
// There are a few edge cases that the item is not like `*.rs`, e.g.,
// Asm *.A51 *.29[kK] *.[68][68][kKsSxX] *.[xX][68][68] *.asm *.ASM *.s *.Shh
// it's ok... | code_fim | hard | {
"lang": "rust",
"repo": "liuchengxu/vim-clap",
"path": "/crates/maple_core/src/tools/ctags/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: liuchengxu/vim-clap path: /crates/maple_core/src/tools/ctags/mod.rs
mod buffer_tag;
mod context_tag;
mod project_tag;
use crate::process::ShellCommand;
use dirs::Dirs;
use itertools::Itertools;
use once_cell::sync::Lazy;
use paths::AbsPathBuf;
use rayon::prelude::*;
use std::collections::HashMa... | code_fim | hard | {
"lang": "rust",
"repo": "liuchengxu/vim-clap",
"path": "/crates/maple_core/src/tools/ctags/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lagudomeze/feign-rs path: /feign_derive/tests/test_macro.rs
use failure::Error;
use serde::{
Deserialize,
Serialize,
};
use feign_derive::{feign, put};
#[derive(Serialize, Deserialize, Debug)]
#[serde(rename_all = "PascalCase")]
pub struct RegisterService {
pub id: String,
pub ... | code_fim | medium | {
"lang": "rust",
"repo": "lagudomeze/feign-rs",
"path": "/feign_derive/tests/test_macro.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[test]
fn it_works() {
let ip = IpAddr::from([127, 0, 0, 1]);
let socket_addr = SocketAddr::new(ip, 8600);
let client = build_iclient(socket_addr).expect("haha");
let addr = std::net::SocketAddr::from_str("127.0.0.1:8080").expect("");
let service = Regist... | code_fim | hard | {
"lang": "rust",
"repo": "lagudomeze/feign-rs",
"path": "/feign_derive/tests/test_macro.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn get_ref(&self) -> RuleRef {
RuleRef(self.name.clone())
}
}
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct RuleRef(pub String);
impl PartialEq<String> for RuleRef {
fn eq(&self, other: &String) -> bool {
&self.0 == other
}
}
impl From<Rule> for RuleRef {
fn ... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/xay",
"path": "/ninja/src/blocks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: SolarLiner/xay path: /ninja/src/blocks.rs
use std::collections::HashMap;
use crate::pretty::variable;
use super::pretty::{
Annotation::{self, *},
Pretty,
};
use pretty::{DocAllocator, DocBuilder};
use std::hash::{Hash, Hasher};
#[derive(Clone, Debug)]
pub struct Rule {
pub(crate) ... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/xay",
"path": "/ninja/src/blocks.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.0
}
}
#[derive(Clone, Debug)]
pub struct Build {
pub rule: String,
pub outputs: Vec<String>,
pub inputs: Vec<String>,
pub vars: HashMap<String, String>,
}
impl PartialEq<Self> for Build {
fn eq(&self, other: &Self) -> bool {
self.rule == other.rule && self.ou... | code_fim | hard | {
"lang": "rust",
"repo": "SolarLiner/xay",
"path": "/ninja/src/blocks.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn serialize<W>(&self, wrt: &mut W) -> Result<(), Error>
where
W: WriteBytesExt,
{
self.0.serialize(wrt)?;
self.1.serialize(wrt)
}
}
impl<T: BinarySerializable + Float> BinarySerializable for OrderedFloat<T> {
fn deserialize<'a>(all_input: &'a [u8], input: &'a ... | code_fim | hard | {
"lang": "rust",
"repo": "Airtnp/utils-rs",
"path": "/serde_nom/src/binary_serialize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Airtnp/utils-rs path: /serde_nom/src/binary_serialize.rs
use byteorder::WriteBytesExt;
use nom::{
bytes::complete::take,
error::{ParseError, VerboseError},
IResult,
};
use num::Float;
use ordered_float::OrderedFloat;
use std::{convert::TryInto, io::Error, mem::size_of};
// issue (#6... | code_fim | hard | {
"lang": "rust",
"repo": "Airtnp/utils-rs",
"path": "/serde_nom/src/binary_serialize.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub trait FromBytes {
const SIZE: usize;
fn from_ne_bytes(input: &[u8]) -> Self;
fn to_ne_bytes(&self) -> Vec<u8>;
}
derive_fb_primitives!(i8, i16, i32, i64, i128, u8, u16, u32, u64, u128, isize, usize, f32, f64);
pub trait BinarySerializable {
fn deserialize<'a>(all_input: &'a [u8], inp... | code_fim | hard | {
"lang": "rust",
"repo": "Airtnp/utils-rs",
"path": "/serde_nom/src/binary_serialize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: gnoliyil/fuchsia path: /src/recovery/progress-ui/src/main.rs
// Copyright 2022 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
use anyhow::{Error, Result};
#[cfg(feature = "debug_touch_to_update")]... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/recovery/progress-ui/src/main.rs",
"mode": "psm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_suffix|> app_context: &AppSender,
status: Status,
percent_complete: f32,
elapsed_time: Option<Duration>,
) {
match status {
Status::Active => {
let progress = percent_complete / 100.0;
let progress_message = if elapsed_time.is_... | code_fim | hard | {
"lang": "rust",
"repo": "gnoliyil/fuchsia",
"path": "/src/recovery/progress-ui/src/main.rs",
"mode": "spm",
"license": "BSD-2-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ShotaroTsuji/teia path: /src/indexed_vec.rs
use crate::traits::{IndexedSet, IndexedSetIters};
#[derive(Debug, Clone)]
pub struct IndexedVec<T> {
vec: Vec<T>,
start: usize,
}
impl<T> IndexedSet<T> for IndexedVec<T> {
#[inline]
fn new(start: usize) -> Self {
IndexedVec {
... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/teia",
"path": "/src/indexed_vec.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<T> std::ops::IndexMut<usize> for IndexedVec<T> {
fn index_mut(&mut self, index: usize) -> &mut T {
self.get_mut(index).unwrap()
}
}
impl<T> std::ops::Index<std::ops::Range<usize>> for IndexedVec<T> {
type Output = [T];
fn index(&self, index: std::ops::Range<usize>) -> &Self:... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/teia",
"path": "/src/indexed_vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &mut self.vec[index.start - self.start..]
}
}
impl<T> std::ops::Index<std::ops::RangeTo<usize>> for IndexedVec<T> {
type Output = [T];
fn index(&self, index: std::ops::RangeTo<usize>) -> &Self::Output {
&self.vec[..index.end - self.start]
}
}
impl<T> std::ops::IndexMut<s... | code_fim | hard | {
"lang": "rust",
"repo": "ShotaroTsuji/teia",
"path": "/src/indexed_vec.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: jklina/rusty_space_clawer path: /src/main.rs
mod session;
mod player;
mod team;
mod contract;
mod ship;
mod space_time;
mod location;
mod string_option;
mod post_command;
use contract::Contract;
use player::Players;
use location::Location;
use session::Session;
use post_command::PostCommand;
use... | code_fim | hard | {
"lang": "rust",
"repo": "jklina/rusty_space_clawer",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ("refuel", None) => {
let command = String::from("refuel");
let resp = PostCommand::send(command, None, client, server_url);
println!("{}", resp.await.unwrap());
},
("stop",... | code_fim | hard | {
"lang": "rust",
"repo": "jklina/rusty_space_clawer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> ("launch", None) => {
let command = String::from("launch");
let resp = PostCommand::send(command, None, client, server_url);
println!("{}", resp.await.unwrap());
},
("load_ca... | code_fim | hard | {
"lang": "rust",
"repo": "jklina/rusty_space_clawer",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn flush(&mut self) {
let text = unsafe {
let buffer = core::slice::from_raw_parts(self.as_ptr(), self.len);
core::str::from_utf8_unchecked(buffer)
};
(self.fun)(text);
self.len = 0;
}
#[inline]
fn copy_text<'a>(&mut self, text: ... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/rogu",
"path": "/src/out/wasm.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: DoumanAsh/rogu path: /src/out/wasm.rs
use wasm_bindgen::prelude::wasm_bindgen;
use core::{mem, ptr, cmp};
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
fn error(s: &str);
#[wasm_bindgen(js_namespace = console)]
fn warn(s: &str);
#[wasm_bindgen(js_name... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/rogu",
"path": "/src/out/wasm.rs",
"mode": "psm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> if text.len() == 0 {
break;
} else {
self.flush();
}
}
if unsafe { *self.as_ptr().add(self.len - 1) } == b'\n' {
self.len -= 1;
self.flush();
}
}
}
#[cfg(feature = "ufmt")]
impl ufmt::... | code_fim | hard | {
"lang": "rust",
"repo": "DoumanAsh/rogu",
"path": "/src/out/wasm.rs",
"mode": "spm",
"license": "BSL-1.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: armandli/rnn_example path: /src/main.rs
extern crate rnn_example;
extern crate rulinalg;
use std::path::Path;
<|fim_suffix|>extern crate rand;
use rand::Rng;
fn main() {
let input = "./input.txt";
println!("input = {}", input);
let input_file = Path::new(input);
let (data, en... | code_fim | medium | {
"lang": "rust",
"repo": "armandli/rnn_example",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> //this was good enough after 600 iterations
// let rnn = RNNTextGen2::train(data, enc, etoc, ctoe, 100, 2000, 25, 1e-1);
let rnn = LSTMTextGen::train(data, enc, etoc, ctoe, 100, 2000, 25, 1e-1, 0.99);
}<|fim_prefix|>// repo: armandli/rnn_example path: /src/main.rs
extern crate rnn_example;
ex... | code_fim | medium | {
"lang": "rust",
"repo": "armandli/rnn_example",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("{}", writer.run());
}<|fim_prefix|>// repo: lonesometraveler/font-to-byte-array path: /src/main.rs
use std::env;
use std::process;
<|fim_middle|>use font2bytes::FontToBytes;
fn main() {
let writer = FontToBytes::new(env::args()).unwrap_or_else(|err| {
eprintln!("problem parsin... | code_fim | hard | {
"lang": "rust",
"repo": "lonesometraveler/font-to-byte-array",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: lonesometraveler/font-to-byte-array path: /src/main.rs
use std::env;
use std::process;
<|fim_suffix|> let writer = FontToBytes::new(env::args()).unwrap_or_else(|err| {
eprintln!("problem parsing arguments: {}", err);
process::exit(1);
});
println!("{}", writer.run())... | code_fim | easy | {
"lang": "rust",
"repo": "lonesometraveler/font-to-byte-array",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let writer = FontToBytes::new(env::args()).unwrap_or_else(|err| {
eprintln!("problem parsing arguments: {}", err);
process::exit(1);
});
println!("{}", writer.run());
}<|fim_prefix|>// repo: lonesometraveler/font-to-byte-array path: /src/main.rs
use std::env;
use std::process... | code_fim | easy | {
"lang": "rust",
"repo": "lonesometraveler/font-to-byte-array",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: rust-lang/rustc-perf path: /collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f446/i2c1/cr1.rs
- Acknowledge/PEC Position (for data reception)"]
pub struct POS_W<'a> {
w: &'a mut W,
}
impl<'a> POS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn vari... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f446/i2c1/cr1.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> &self.0
}
}
#[doc = "Field `ENPEC` writer - PEC enable"]
pub struct ENPEC_W<'a> {
w: &'a mut W,
}
impl<'a> ENPEC_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: ENPEC_A) -> &'a mut W {
self.bit(variant.into())
}
... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f446/i2c1/cr1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> variant as u8 != 0
}
}
#[doc = "Field `PE` reader - Peripheral enable"]
pub struct PE_R(crate::FieldReader<bool, PE_A>);
impl PE_R {
pub(crate) fn new(bits: bool) -> Self {
PE_R(crate::FieldReader::new(bits))
}
#[doc = r"Get enumerated values variant"]
#[inline(always)]... | code_fim | hard | {
"lang": "rust",
"repo": "rust-lang/rustc-perf",
"path": "/collector/compile-benchmarks/stm32f4-0.14.0/src/stm32f446/i2c1/cr1.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: harpsword/tex-rs path: /src/pascal.rs
'_>) -> fmt::Result {
assert!(*self <= char::MAX);
for ch in crate::unicode_support::chars_from_generalized_char(*self) {
write!(f, "{}", ch)?;
}
Ok(())
}
}
macro_rules! define_ranged_unsigned_integer {
($... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/pascal.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> &(self.0)[idx as usize - <$start_typenum as typenum::Unsigned>::$typenum_const as usize]
}
}
impl<ELEMENT> core::ops::IndexMut<$base_index_type> for $name<ELEMENT>
{
fn index_mut(&mut self, idx: $base_index_type) -> &mut ELEMENT {
... | code_fim | hard | {
"lang": "rust",
"repo": "harpsword/tex-rs",
"path": "/src/pascal.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.