text stringlengths 232 16.3k | domain stringclasses 1
value | difficulty stringclasses 3
values | meta dict |
|---|---|---|---|
<|fim_prefix|>// repo: jean-airoldie/libzmq-rs path: /libzmq/src/endpoint.rs
elf) -> Self::IntoIter {
Some(self).into_iter()
}
}
impl From<UdpAddr> for Endpoint {
fn from(addr: UdpAddr) -> Endpoint {
Endpoint::Udp(addr)
}
}
impl<'a> From<&'a UdpAddr> for Endpoint {
fn from(addr: &'a U... | code_fim | hard | {
"lang": "rust",
"repo": "jean-airoldie/libzmq-rs",
"path": "/libzmq/src/endpoint.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: RSSchermer/web_glitz.rs path: /web_glitz/src/image/texture_cube.rs
mipmap chain for the base image for each of its 6
/// faces. See the module documentation for [web_glitz::image] for more information on mipmaps.
///
/// Note that a [TextureCube] does not necessarily have to store a complete mip... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/image/texture_cube.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> (0..self.end).get(levels)
}
unsafe fn get_unchecked(self, levels: &'a Levels<F>) -> Self::Output {
(0..self.end).get_unchecked(levels)
}
}
impl<'a, F> LevelsIndex<'a, F> for RangeToInclusive<usize>
where
F: 'a,
{
type Output = Levels<'a, F>;
fn get(self, levels: ... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/image/texture_cube.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> gl.tex_storage_2d(
Gl::TEXTURE_CUBE_MAP,
levels,
F::ID,
data.width as i32,
data.height as i32,
);
gl.tex_parameteri(Gl::TEXTURE_CUBE_MAP, Gl::TEXTURE_MAX_LEVEL, levels);
unsafe {
*data.id.get() = Some... | code_fim | hard | {
"lang": "rust",
"repo": "RSSchermer/web_glitz.rs",
"path": "/web_glitz/src/image/texture_cube.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>:new(((self.bits >> 19) & 0x03) as u8)
}
#[doc = "Bit 22 - Interrupt enable bit of the message counter"]
#[inline(always)]
pub fn cfcie(&self) -> CFCIE_R {
CFCIE_R::new(((self.bits >> 22) & 0x01) != 0)
}
#[doc = "Bit 23 - Counter overflow flag messages"]
#[inline(always... | code_fim | hard | {
"lang": "rust",
"repo": "Newlifer/k1921vk01t-pac",
"path": "/src/nt_can/can_node/nfcr.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Newlifer/k1921vk01t-pac path: /src/nt_can/can_node/nfcr.rs
#[doc = "Reader of register NFCR"]
pub type R = crate::R<u32, super::NFCR>;
#[doc = "Writer for register NFCR"]
pub type W = crate::W<u32, super::NFCR>;
#[doc = "Register NFCR `reset()`'s with value 0"]
impl crate::ResetValue for super::... | code_fim | hard | {
"lang": "rust",
"repo": "Newlifer/k1921vk01t-pac",
"path": "/src/nt_can/can_node/nfcr.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn point_at_parameter(&self, t: f32) -> Vector3<f32> {
self.origin + t * self.direction
}
}<|fim_prefix|>// repo: emstresh/Rust-Raytracer path: /src/ray.rs
use cgmath::{
Vector3
};
pub struct Ray {
pub origin: Vector3<f32>,
pub direction: Vector3<f32>,
pub i... | code_fim | hard | {
"lang": "rust",
"repo": "emstresh/Rust-Raytracer",
"path": "/src/ray.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: emstresh/Rust-Raytracer path: /src/ray.rs
use cgmath::{
Vector3
};
pub struct Ray {
pub origin: Vector3<f32>,
pub direction: Vector3<f32>,
pub inv_direction: Vector3<f32>,
pub time: f32
}
<|fim_suffix|> pub fn point_at_parameter(&self, t: f32) -> Vector3<f32> ... | code_fim | hard | {
"lang": "rust",
"repo": "emstresh/Rust-Raytracer",
"path": "/src/ray.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let raw_size = raw_program.len();
let mut machine = Machine::new(30_000);
if opt.verbose {
println!("Processing raw program...")
}
machine.load_program(raw_program, opt.optimise);
if opt.verbose {
println!("Original program size: {} instructions", raw_size);
... | code_fim | hard | {
"lang": "rust",
"repo": "juamms/bfi",
"path": "/src/main.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: juamms/bfi path: /src/main.rs
extern crate structopt;
use io::Read;
use machine::Machine;
use std::path::PathBuf;
use std::{fs, io};
use structopt::StructOpt;
mod machine;
#[derive(StructOpt)]
#[structopt(
name = "bfi",
version = "1.1.0",
about = "An experimental Brainfuck interpr... | code_fim | hard | {
"lang": "rust",
"repo": "juamms/bfi",
"path": "/src/main.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Create basic Pod status patch with container status and pod conditions
pub fn make_status_with_containers_and_condition(
phase: Phase,
reason: &str,
container_statuses: Vec<KubeContainerStatus>,
init_container_statuses: Vec<KubeContainerStatus>,
conditions: Vec<KubePodCondition>,
)... | code_fim | hard | {
"lang": "rust",
"repo": "djc/agent",
"path": "/src/provider/states.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: djc/agent path: /src/provider/states.rs
use k8s_openapi::api::core::v1::ContainerStatus as KubeContainerStatus;
use k8s_openapi::api::core::v1::PodCondition as KubePodCondition;
use kubelet::pod::state::prelude::*;
use kubelet::pod::{Phase, Status};
<|fim_suffix|>/// When called in a state's `n... | code_fim | medium | {
"lang": "rust",
"repo": "djc/agent",
"path": "/src/provider/states.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let buffer = self.buffer.read();
if buffer.get(key, &mut record) {
*value = record.value;
return true;
}
drop(buffer);
let levels = self.levels.read();
for level in levels.iter() {
if level.get(key, &mut record) {
... | code_fim | hard | {
"lang": "rust",
"repo": "tinalu99/SysFx-Presentation",
"path": "/src/lib_lsm_tree/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let levels = self.levels.read();
for level in levels.iter() {
if level.get(key, &mut record) {
*value = record.value;
return true;
}
}
false
}
pub fn print_stats(&self) {
let levels = self.levels.r... | code_fim | hard | {
"lang": "rust",
"repo": "tinalu99/SysFx-Presentation",
"path": "/src/lib_lsm_tree/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: tinalu99/SysFx-Presentation path: /src/lib_lsm_tree/mod.rs
use std::collections::{HashSet};
use log::{debug};
use parking_lot::{RwLock, RwLockWriteGuard};
use std::i32;
use crate::configuration::CONFIGURATION;
use crate::lib_template::{Record};
use crate::lib_on_disk::lib_disk_level::{DiskLev... | code_fim | hard | {
"lang": "rust",
"repo": "tinalu99/SysFx-Presentation",
"path": "/src/lib_lsm_tree/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 0x-r4bbit/vibranium path: /src/accounts_manager/mod.rs
pub mod error;
use crate::blockchain::connector::BlockchainConnector;
use web3::types::Address;
pub struct AccountsManager<'a> {
connector: &'a BlockchainConnector,
}
<|fim_suffix|> pub fn get_node_accounts(&self) -> Result<Vec<Address... | code_fim | medium | {
"lang": "rust",
"repo": "0x-r4bbit/vibranium",
"path": "/src/accounts_manager/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl<'a> AccountsManager<'a> {
pub fn new(connector: &'a BlockchainConnector) -> AccountsManager<'a> {
AccountsManager {
connector,
}
}
pub fn get_node_accounts(&self) -> Result<Vec<Address>, error::AccountsError> {
self.connector.accounts().map_err(|err| error::AccountsError::Oth... | code_fim | medium | {
"lang": "rust",
"repo": "0x-r4bbit/vibranium",
"path": "/src/accounts_manager/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> /// Returns a 2-dimensional region of valid pixel coordinates for a level with tile coordinates `(dx, dy)` and level number `(lx, ly)`
///
/// # Errors
/// * [`Error::InvalidArgument`] - if the passed tile coordinates are invalid
/// * [`Error::Base`] - if any other error occurs
/... | code_fim | hard | {
"lang": "rust",
"repo": "anderslanglands/openexr-bind",
"path": "/openexr-rs/src/deep/deep_tiled_output_file.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anderslanglands/openexr-bind path: /openexr-rs/src/deep/deep_tiled_output_file.rs
ding_mode()`](DeepTiledOutputFile::level_rounding_mode()) is [`LevelRoundingMode::RoundUp`] or [`LevelRoundingMode::RoundDown`]
///
pub fn num_levels(&self) -> Result<i32> {
let mut v = 0;
u... | code_fim | hard | {
"lang": "rust",
"repo": "anderslanglands/openexr-bind",
"path": "/openexr-rs/src/deep/deep_tiled_output_file.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: anderslanglands/openexr-bind path: /openexr-rs/src/deep/deep_tiled_output_file.rs
ccurs
///
pub fn set_frame_buffer(
&mut self,
frame_buffer: &DeepFrameBuffer,
) -> Result<()> {
unsafe {
sys::Imf_DeepTiledOutputFile_setFrameBuffer(
... | code_fim | hard | {
"lang": "rust",
"repo": "anderslanglands/openexr-bind",
"path": "/openexr-rs/src/deep/deep_tiled_output_file.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Pro-YY/rust-learn path: /area/src/main.rs
fn add(x: i32, y: i32) -> i32 {
x + y //expression orientation
// return x + y; // poor style
}
fn wrong() -> ! {
panic!("The function never returns!");
}
/*
fn foo(a: [T; N]) -> [T; N] {
println!("len: {}, first: {}", a.len(), a[0]);
... | code_fim | hard | {
"lang": "rust",
"repo": "Pro-YY/rust-learn",
"path": "/area/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let c = Circle{x: 0.0, y: 0.0, radius: 1.0};
let s = Square{x: 0.0, y: 0.0, side: 1.0};
println!("area: {:?}", c);
println!("area: {}", c.area());
println!("area: {:?}", s);
println!("area: {}", s.area());
}<|fim_prefix|>// repo: Pro-YY/rust-learn path: /area/src/main.rs
fn add(x:... | code_fim | hard | {
"lang": "rust",
"repo": "Pro-YY/rust-learn",
"path": "/area/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn print_area<T: HasArea>(shape: T) -> f64 {
let a = shape.area();
println!("area: {:?}", a);
a
}
fn main() {
let c = Circle{x: 0.0, y: 0.0, radius: 1.0};
let s = Square{x: 0.0, y: 0.0, side: 1.0};
println!("area: {:?}", c);
println!("area: {}", c.area());
println!("area: ... | code_fim | hard | {
"lang": "rust",
"repo": "Pro-YY/rust-learn",
"path": "/area/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let alldevs: *mut PcapInterface = call_findalldevs();
if alldevs.is_null() {
println!("error retrieving device list");
return String::from("");
}
// Get the First Pcap Device Struct
let mut curr_dev_ptr = alldevs as *mut PcapInterface;
... | code_fim | hard | {
"lang": "rust",
"repo": "cyrex562/RustPcap",
"path": "/src/main.rs",
"mode": "spm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cyrex562/RustPcap path: /src/main.rs
extern crate libc;
extern crate libloading;
use std::ffi::CString;
use std::ffi::CStr;
use std::str;
use libloading::{Library, Symbol};
#[cfg(windows)] extern create winapi;
pub enum PcapCapInstance {}
pub enum PcapDumper {}
pub enum BpfProgram {}
#[re... | code_fim | hard | {
"lang": "rust",
"repo": "cyrex562/RustPcap",
"path": "/src/main.rs",
"mode": "psm",
"license": "Unlicense",
"source": "the-stack-v2"
} |
<|fim_suffix|> Paren(ref expr) => write!(format, "({})", expr),
AnyFunction(name, args) => {
write!(
format,
"{}({})",
name,
args.iter().map(|e| e.to_string()).join(",")
)
... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-tokens/src/tokens/expression.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-tokens/src/tokens/expression.rs
en_operation(&self) -> bool;
fn token_operation(&self) -> &UnaryTokenOperation;
fn token(&self) -> &Self::Token;
fn is_prefix_label(&self) -> bool;
fn prefix(&self) -> &LabelPrefix;
fn is_binary_operation(&sel... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-tokens/src/tokens/expression.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: cpcsdk/rust.cpclib path: /cpclib-tokens/src/tokens/expression.rs
nwrap_or(exp);
exp.to_owned()
}
}
impl Display for Expr {
fn fmt(&self, format: &mut Formatter<'_>) -> fmt::Result {
use self::Expr::*;
match self {
Rnd => write!(format, "RND()"),
... | code_fim | hard | {
"lang": "rust",
"repo": "cpcsdk/rust.cpclib",
"path": "/cpclib-tokens/src/tokens/expression.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let criu = Criu::new()?;
criu.dump(options)?;
Ok(())
}<|fim_prefix|>// repo: Furisto/criu path: /src/main.rs
use std::{fs::{self, File}, io::stdin, os::unix::prelude::AsRawFd};
<|fim_middle|>use criu::{criu::Criu, rpc};
use anyhow::Result;
fn main() -> Result<()> {
let image_dir = "/tm... | code_fim | hard | {
"lang": "rust",
"repo": "Furisto/criu",
"path": "/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Furisto/criu path: /src/main.rs
use std::{fs::{self, File}, io::stdin, os::unix::prelude::AsRawFd};
use criu::{criu::Criu, rpc};
use anyhow::Result;
<|fim_suffix|> let image_dir = "/tmp/criu/image_dir";
fs::create_dir_all(image_dir)?;
let image_dir = File::open(image_dir)?;
let... | code_fim | medium | {
"lang": "rust",
"repo": "Furisto/criu",
"path": "/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: michaeldisaro/repo path: /src/services/n.rs
use crate::traits::vec_traits::VecExtension;
use std::process::Command;
pub fn set_node_version(version: &String) {
if version.is_empty() {
return;
}
<|fim_suffix|>arg(version).output().expect("n error!");
output.stderr.log_and_... | code_fim | medium | {
"lang": "rust",
"repo": "michaeldisaro/repo",
"path": "/src/services/n.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>arg(version).output().expect("n error!");
output.stderr.log_and_die_if_exists();
}<|fim_prefix|>// repo: michaeldisaro/repo path: /src/services/n.rs
use crate::traits::vec_traits::VecExtension;
use std::process::Command;
pub fn set_n<|fim_middle|>ode_version(version: &String) {
if version.is_emp... | code_fim | medium | {
"lang": "rust",
"repo": "michaeldisaro/repo",
"path": "/src/services/n.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[allow(non_snake_case)]
#[derive(Debug, Default, Delegate, Serialize, Deserialize, PartialEq)]
#[delegate(ActivityStreamObjectProperties, target = "_base")]
pub struct ActivityStreamOrderedCollection {
#[serde(skip_serializing_if = "Option::is_none", default)]
#[serde(deserialize_with = "Activity... | code_fim | hard | {
"lang": "rust",
"repo": "teromene/activityrust",
"path": "/src/entities/orderedcollection.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: teromene/activityrust path: /src/entities/orderedcollection.rs
use crate::content::*;
use crate::entities::collection::ActivityStreamCollection;
use crate::entities::entity::{
ActivityStreamEntity, ActivityStreamEntityType, BoxedActivityStreamEntity,
};
use crate::entities::object::ActivityS... | code_fim | hard | {
"lang": "rust",
"repo": "teromene/activityrust",
"path": "/src/entities/orderedcollection.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: ryskov/rust-cc path: /src/generator.rs
use AST;
use Symbol;
use StatementType;
use UnaryOperator;
use BinaryOperator;
struct Generator {
buf: String,
expression_stack: Vec<String>
}
impl Generator {
fn new() -> Generator {
Generator {
buf: String... | code_fim | hard | {
"lang": "rust",
"repo": "ryskov/rust-cc",
"path": "/src/generator.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> self.expression_stack.push(format!("{}push %rax\n{}pop %rbx\naddq %rbx, %rax\n", op1, op2));
},
&BinaryOperator::Multiplication => {
let op2 = self.expression_stack.pop().unwrap();
let op1 =... | code_fim | hard | {
"lang": "rust",
"repo": "ryskov/rust-cc",
"path": "/src/generator.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: agi90/oxi-pdf path: /pdf/src/types.rs
use std::collections::HashMap;
use crate::parser;
use crate::parser::{
PdfObject,
PdfDictionary,
OptionalFrom,
};
// 7.9.5
#[derive(Debug, Clone)]
pub struct Rectangle {
ll_x: f64,
ll_y: f64,
ur_x: f64,
ur_y: f64,
}
<|fim_suffi... | code_fim | medium | {
"lang": "rust",
"repo": "agi90/oxi-pdf",
"path": "/pdf/src/types.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let (upper_limit, lower_limit) =
if let Some(mut limits) = data.integer_array("Limits") {
(limits.next(), limits.next())
} else {
(None, None)
};
Some(NumberTreeNode {
kids: data.map_reference_array("Kids", pdf, NumberTre... | code_fim | hard | {
"lang": "rust",
"repo": "agi90/oxi-pdf",
"path": "/pdf/src/types.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>"`read()` method returns [gpio::R](gpio::R) reader structure"]
impl crate::Readable for GPIO {}
#[doc = "`write(|w| ..)` method takes [gpio::W](gpio::W) writer structure"]
impl crate::Writable for GPIO {}
#[doc = "Pad control register"]
pub mod gpio;
#[doc = "Pad control register\n\nThis register you can ... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/pads_bank0.rs",
"mode": "spm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: 9ary/rp2040-pac path: /src/pads_bank0.rs
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Voltage select. Per bank control"]
pub voltage_select: VOLTAGE_SELECT,
#[doc = "0x04 - Pad control register"]
pub gpio: [GPIO; 30],
#[doc = "0x7c - Pad co... | code_fim | hard | {
"lang": "rust",
"repo": "9ary/rp2040-pac",
"path": "/src/pads_bank0.rs",
"mode": "psm",
"license": "BSD-3-Clause",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: francescop/rust_snake path: /snake/src/lib.rs
pub struct Snake {
pub length: u32
}
<|fim_suffix|> let mut snake = Snake::new();
snake.eat();
assert_eq!(snake.length, 2);
}<|fim_middle|>impl Snake {
pub fn new() -> Snake {
Snake { length: 1 }
}
pub fn eat(&mut... | code_fim | hard | {
"lang": "rust",
"repo": "francescop/rust_snake",
"path": "/snake/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>#[test]
fn snake_eat_food() {
let mut snake = Snake::new();
snake.eat();
assert_eq!(snake.length, 2);
}<|fim_prefix|>// repo: francescop/rust_snake path: /snake/src/lib.rs
pub struct Snake {
pub length: u32
}
impl Snake {
pub fn new() -> Snake {
Snake { length: 1 }
}
... | code_fim | medium | {
"lang": "rust",
"repo": "francescop/rust_snake",
"path": "/snake/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: francescop/rust_snake path: /snake/src/lib.rs
pub struct Snake {
pub length: u32
}
impl Snake {
pub fn new() -> Snake {
Snake { length: 1 }
}
pub fn eat(&mut self) {
self.length += 1;
}
}
<|fim_suffix|>#[test]
fn snake_eat_food() {
let mut snake = Snake... | code_fim | medium | {
"lang": "rust",
"repo": "francescop/rust_snake",
"path": "/snake/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let ret = Solution::merge_trees(Some(root1), Some(root2)).unwrap();
assert_eq!(ret.borrow().val, 3);
assert_eq!(ret.borrow().left.clone().unwrap().borrow().val, 4);
assert_eq!(ret.borrow().right.clone().unwrap().borrow().val, 5);
assert_eq!(ret.borrow().left.clone()... | code_fim | hard | {
"lang": "rust",
"repo": "flame4/leetcode",
"path": "/src/easy/merge_two_binary_trees_617.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: flame4/leetcode path: /src/easy/merge_two_binary_trees_617.rs
use crate::Solution;
use crate::treenode::TreeNode;
use std::rc::Rc;
use std::cell::RefCell;
impl Solution {
// 把t2的值加到t1上.
pub fn merge_trees(t1: Option<Rc<RefCell<TreeNode>>>, t2: Option<Rc<RefCell<TreeNode>>>)
-> O... | code_fim | hard | {
"lang": "rust",
"repo": "flame4/leetcode",
"path": "/src/easy/merge_two_binary_trees_617.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: fpetkovski/linkerd2-proxy path: /linkerd/duplex/src/lib.rs
#![deny(warnings, rust_2018_idioms)]
use bytes::{Buf, BufMut};
use futures::ready;
use io::{AsyncRead, AsyncWrite};
use linkerd_io as io;
use pin_project::pin_project;
use std::task::{Context, Poll};
use std::{future::Future, pin::Pin};... | code_fim | hard | {
"lang": "rust",
"repo": "fpetkovski/linkerd2-proxy",
"path": "/linkerd/duplex/src/lib.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> assert!(self.write_pos >= self.read_pos + cnt);
self.read_pos += cnt;
}
}
unsafe impl BufMut for CopyBuf {
fn remaining_mut(&self) -> usize {
self.buf.len() - self.write_pos
}
fn chunk_mut(&mut self) -> &mut bytes::buf::UninitSlice {
unsafe {
/... | code_fim | hard | {
"lang": "rust",
"repo": "fpetkovski/linkerd2-proxy",
"path": "/linkerd/duplex/src/lib.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> Ok(Ir {
items: vec![],
ns: self.pb.to_string_lossy().to_string(),
})
}
}
fn from_str(input: &str, pb: PathBuf) -> eyre::Result<InputMd> {
let arena = Arena::new();
let d = parse_document(&arena, input, &ComrakOptions::default());
process_node(&d);
... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/topics-2",
"path": "/input_md/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>///
/// Single-line text items are identifiers and follow special rules.
///
fn collect_single_line_text<'a>(node: &'a AstNode<'a>) -> String {
node.children()
.filter_map(|n| match &n.data.borrow().value {
NodeValue::Text(t) => Some(std::str::from_utf8(t).unwrap().to_string()),
... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/topics-2",
"path": "/input_md/src/lib.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: shakyShane/topics-2 path: /input_md/src/lib.rs
use comrak::nodes::{AstNode, NodeHeading, NodeValue};
use comrak::{parse_document, Arena, ComrakOptions};
use eyre::Report;
use ir::Ir;
use std::convert::TryInto;
use std::path::PathBuf;
#[derive(Debug, Default)]
pub struct InputMd {
pb: PathBu... | code_fim | hard | {
"lang": "rust",
"repo": "shakyShane/topics-2",
"path": "/input_md/src/lib.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> let now = Instant::now();
let data = "2,0,1,7,4,14,18";
let input : Vec<u32> = data.split(",").map(|x| x.parse().unwrap()).collect();
println!("Read input took {:?}", now.elapsed());
let now = Instant::now();
part1(&input, 2020);
println!("Part 1 took {:?}", now.elapsed())... | code_fim | hard | {
"lang": "rust",
"repo": "razpeitia/advent_of_code_2020",
"path": "/Day15/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn main() {
let now = Instant::now();
let data = "2,0,1,7,4,14,18";
let input : Vec<u32> = data.split(",").map(|x| x.parse().unwrap()).collect();
println!("Read input took {:?}", now.elapsed());
let now = Instant::now();
part1(&input, 2020);
println!("Part 1 took {:?}", no... | code_fim | hard | {
"lang": "rust",
"repo": "razpeitia/advent_of_code_2020",
"path": "/Day15/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: razpeitia/advent_of_code_2020 path: /Day15/src/main.rs
use std::collections::HashMap;
use std::time::Instant;
#[derive(Debug)]
enum Last {
Once(u32),
Twice(u32, u32)
}
fn update_last_spoken(last_spoken : &mut HashMap<u32, Last>, spoken : u32, turn : u32) {
match last_spoken.get(&sp... | code_fim | hard | {
"lang": "rust",
"repo": "razpeitia/advent_of_code_2020",
"path": "/Day15/src/main.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dwuggh/15-puzzle-helper path: /src/lib/types/mov.rs
use std::fmt;
// the four move types(directions), used for scramble representation
// direction is the empty site moving direction
#[derive(PartialEq, Eq, Clone, Debug, Hash)]
pub enum Move {
Left,
Right,
Up,
Down,
None,
}
... | code_fim | medium | {
"lang": "rust",
"repo": "dwuggh/15-puzzle-helper",
"path": "/src/lib/types/mov.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> match self {
Move::Left => { Move::Right },
Move::Right => { Move::Left },
Move::Up => { Move::Down },
Move::Down => { Move::Up },
Move::None => { Move::None }
}
}
}<|fim_prefix|>// repo: dwuggh/15-puzzle-helper path: /src/lib/types/mov.rs
use std::fmt;
// the four move typ... | code_fim | medium | {
"lang": "rust",
"repo": "dwuggh/15-puzzle-helper",
"path": "/src/lib/types/mov.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: StewartCanva/rust-skia path: /skia-safe/src/gpu.rs
mod backend_drawable_info;
pub use self::backend_drawable_info::*;
mod backend_surface;
pub use self::backend_surface::*;
mod backend_surface_mutable_state;
pub use self::backend_surface_mutable_state::*;
pub mod context_options;
pub use self... | code_fim | medium | {
"lang": "rust",
"repo": "StewartCanva/rust-skia",
"path": "/skia-safe/src/gpu.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> _context(context)
}
fn _recording_context_mut(_context: &mut RecordingContext) {}
fn _context_mut(context: &mut DirectContext) {
_recording_context_mut(context)
}
fn _direct_context_mut(context: &mut DirectContext) {
_context_mut(context)
}
}<|fim_prefix|>/... | code_fim | hard | {
"lang": "rust",
"repo": "StewartCanva/rust-skia",
"path": "/skia-safe/src/gpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> fn _context(context: &DirectContext) {
_recording_context(context)
}
fn _direct_context(context: &DirectContext) {
_context(context)
}
fn _recording_context_mut(_context: &mut RecordingContext) {}
fn _context_mut(context: &mut DirectContext) {
_recording_co... | code_fim | hard | {
"lang": "rust",
"repo": "StewartCanva/rust-skia",
"path": "/skia-safe/src/gpu.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: chinatsu/ggetris path: /src/state/tetris/inputstate.rs
pub struct InputState {
pub das: u64,
pub down_frames: u64,
pub left: bool<|fim_suffix|> left: false,
right: false,
down: false,
}
}
}<|fim_middle|>,
pub right: bool,
pub down: boo... | code_fim | medium | {
"lang": "rust",
"repo": "chinatsu/ggetris",
"path": "/src/state/tetris/inputstate.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> left: false,
right: false,
down: false,
}
}
}<|fim_prefix|>// repo: chinatsu/ggetris path: /src/state/tetris/inputstate.rs
pub struct InputState {
pub das: u64,
pub down_frames: u64,
pub left: bool<|fim_middle|>,
pub right: bool,
pub down: boo... | code_fim | medium | {
"lang": "rust",
"repo": "chinatsu/ggetris",
"path": "/src/state/tetris/inputstate.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>f::master_resources::MasterResources;
pub use self::state_handler::initialize_state_handler;<|fim_prefix|>// repo: CPSSD/cerberus path: /master/src/initialization/mod.rs
mod dashboard_server;
mod data_layer;
mod grpc_server;
mod master_resources;
mod state_handler;
pub use self::dashboard_server::initia... | code_fim | medium | {
"lang": "rust",
"repo": "CPSSD/cerberus",
"path": "/master/src/initialization/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: CPSSD/cerberus path: /master/src/initialization/mod.rs
mod dashboard_server;
mod data_layer;
mod grpc_server;
mod master_resources;
mod state_handler;
pub use self::dashboard_server::initialize_dashboard_server;
pub use self::data_layer:<|fim_suffix|>f::master_resources::MasterResources;
pub us... | code_fim | medium | {
"lang": "rust",
"repo": "CPSSD/cerberus",
"path": "/master/src/initialization/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: facebookexperimental/MIRAI path: /checker/tests/run-pass/vec_empty_postcondition.rs
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
//
// A test that uses built-i... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/MIRAI",
"path": "/checker/tests/run-pass/vec_empty_postcondition.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>impl Test {
fn new() -> Self {
let res = Self { v: vec![] };
assumed_postcondition!(res.v.is_empty());
res
}
}
pub fn main() {
let t = Test::new();
verify!(t.v.is_empty());
}<|fim_prefix|>// repo: facebookexperimental/MIRAI path: /checker/tests/run-pass/vec_empty_... | code_fim | medium | {
"lang": "rust",
"repo": "facebookexperimental/MIRAI",
"path": "/checker/tests/run-pass/vec_empty_postcondition.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> is Empty"]
#[inline(always)]
pub fn intkntxfemp(&mut self) -> INTKNTXFEMP_W<4> {
INTKNTXFEMP_W::new(self)
}
#[doc = "Bit 6 - IN Endpoint NAK Effective"]
#[inline(always)]
pub fn inepnakeff(&mut self) -> INEPNAKEFF_W<6> {
INEPNAKEFF_W::new(self)
}
#[doc = "B... | code_fim | hard | {
"lang": "rust",
"repo": "em32-rs/efm32hg-pac",
"path": "/src/usb/diep0int.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: em32-rs/efm32hg-pac path: /src/usb/diep0int.rs
#[doc = "Register `DIEP0INT` reader"]
pub struct R(crate::R<DIEP0INT_SPEC>);
impl core::ops::Deref for R {
type Target = crate::R<DIEP0INT_SPEC>;
#[inline(always)]
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl From<crat... | code_fim | hard | {
"lang": "rust",
"repo": "em32-rs/efm32hg-pac",
"path": "/src/usb/diep0int.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bsletten/oxigraph path: /js/src/store.rs
use crate::format_err;
use crate::model::*;
use crate::utils::to_err;
use js_sys::{Array, Map};
use oxigraph::model::NamedOrBlankNode;
use oxigraph::sparql::{PreparedQuery, QueryOptions, QueryResult};
use oxigraph::{DatasetSyntax, Error, FileSyntax, Graph... | code_fim | hard | {
"lang": "rust",
"repo": "bsletten/oxigraph",
"path": "/js/src/store.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn add(&self, quad: &JsValue) -> Result<(), JsValue> {
self.store
.insert(&self.from_js.to_quad(quad)?.try_into()?)
.map_err(to_err)
}
pub fn delete(&self, quad: &JsValue) -> Result<(), JsValue> {
self.store
.remove(&self.from_js.to_quad... | code_fim | hard | {
"lang": "rust",
"repo": "bsletten/oxigraph",
"path": "/js/src/store.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: dprint/dprint path: /crates/dprint/src/utils/table_text.rs
use super::logging::render_text_items_with_width;
use super::logging::LoggerTextItem;
pub struct TableText {
pub lines: Vec<String>,
pub hanging_indent: u16,
}
impl TableText {
pub fn render(&self, indent: u16, terminal_width: Op... | code_fim | hard | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/utils/table_text.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_largest_string_len<'a>(items: impl Iterator<Item = &'a str>) -> usize {
let mut key_lens = items.map(|item| item.chars().count()).collect::<Vec<_>>();
key_lens.sort_unstable();
key_lens.pop().unwrap_or(0)
}<|fim_prefix|>// repo: dprint/dprint path: /crates/dprint/src/utils/table_text.rs
use ... | code_fim | medium | {
"lang": "rust",
"repo": "dprint/dprint",
"path": "/crates/dprint/src/utils/table_text.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let pad_len = 8 - (entry_len % 8);
let mut pad = vec![];
for _ in 0..pad_len {
pad.push(0);
}
let ent = Entry {
ctime: (meta.st_ctime() as i32, meta.st_ctime_nsec() as i32),
mtime: (meta.st_mtime() as i32, meta.st_mtime_nsec() as ... | code_fim | hard | {
"lang": "rust",
"repo": "Babanmei/gitrs",
"path": "/src/index/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Babanmei/gitrs path: /src/index/mod.rs
use std::cell::RefCell;
use std::io::Write;
use std::os::macos::fs::MetadataExt;
use std::path::PathBuf;
use anyhow::Result;
use binwrite::{BinWrite, Endian, WriterOption};
use crate::hasher::generic_blob_hash;
pub mod parse_index;
#[derive(Debug, Clone... | code_fim | hard | {
"lang": "rust",
"repo": "Babanmei/gitrs",
"path": "/src/index/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: IThawk/rust-project path: /rust-master/src/libsyntax/parse/mod.rs
//! The main parser interface.
use crate::ast;
use crate::parse::parser::{Parser, emit_unclosed_delims};
use crate::parse::token::Nonterminal;
use crate::tokenstream::{self, TokenStream, TokenTree};
use crate::print::pprust;
use ... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/libsyntax/parse/mod.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|>/// Given a session and a path and an optional span (for error reporting),
/// add the path to the session's source_map and return the new source_file or
/// error when a file can't be read.
fn try_file_to_source_file(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
-> Result<Lrc<S... | code_fim | hard | {
"lang": "rust",
"repo": "IThawk/rust-project",
"path": "/rust-master/src/libsyntax/parse/mod.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_suffix|> let _buffer_guard = self.channel().buffer_messages_for(consumer_id.into());
let response = self
.channel()
.request(
self.id(),
TransportConsumeRequest {
consumer_id,
producer_id: producer.id()... | code_fim | hard | {
"lang": "rust",
"repo": "versatica/mediasoup",
"path": "/rust/src/router/transport.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: versatica/mediasoup path: /rust/src/router/transport.rs
n usage
/// Check the [RTP Parameters and Capabilities](https://mediasoup.org/documentation/v3/mediasoup/rtp-parameters-and-capabilities/)
/// section for more details (TypeScript-oriented, but concepts apply here as well).
///
... | code_fim | hard | {
"lang": "rust",
"repo": "versatica/mediasoup",
"path": "/rust/src/router/transport.rs",
"mode": "psm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_suffix|> async fn consume_impl(
&self,
consumer_options: ConsumerOptions,
transport_type: TransportType,
rtx: bool,
) -> Result<Consumer, ConsumeError> {
let ConsumerOptions {
producer_id,
rtp_capabilities,
paused,
mid,... | code_fim | hard | {
"lang": "rust",
"repo": "versatica/mediasoup",
"path": "/rust/src/router/transport.rs",
"mode": "spm",
"license": "ISC",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: HumMan/SiteParser-rs path: /src/serialize.rs
use serde_json;
use serde::ser::{Serialize, Serializer, SerializeSeq, SerializeMap};
use std::io::prelude::*;
use zip::write::FileOptions;
use super::model;
use chrono::prelude::*;
<|fim_suffix|>const CATALOG_ARCHIVE_ENTRY: &str = "catalog.json";
co... | code_fim | medium | {
"lang": "rust",
"repo": "HumMan/SiteParser-rs",
"path": "/src/serialize.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>pub fn serialize_catalog(value: &Vec<model::GameInfo>) {
let file = std::fs::File::create(&CATALOG_ZIP).unwrap();
let buffer = std::io::BufWriter::with_capacity(65536, file);
let mut zip = zip::ZipWriter::new(buffer);
let options = FileOptions::default().compression_method(zip::Compression... | code_fim | hard | {
"lang": "rust",
"repo": "HumMan/SiteParser-rs",
"path": "/src/serialize.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> unsafe {
let hwnd = GetForegroundWindow();
GetWindowRect(hwnd, &mut a);
GetWindowRect(GetDesktopWindow(), &mut b);
}
a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom
}<|fim_prefix|>// repo: bretzle/archer path: /polybar/src/util.rs
use winapi::{
shared::windef::... | code_fim | medium | {
"lang": "rust",
"repo": "bretzle/archer",
"path": "/polybar/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bretzle/archer path: /polybar/src/util.rs
use winapi::{
shared::windef::RECT,
um::winuser::{GetDesktopWindow, GetForegroundWindow, GetWindowRect},
};
<|fim_suffix|> unsafe {
let hwnd = GetForegroundWindow();
GetWindowRect(hwnd, &mut a);
GetWindowRect(GetDesktopWindow(), &mut b);
}
a.... | code_fim | medium | {
"lang": "rust",
"repo": "bretzle/archer",
"path": "/polybar/src/util.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> a.left == b.left && a.top == b.top && a.right == b.right && a.bottom == b.bottom
}<|fim_prefix|>// repo: bretzle/archer path: /polybar/src/util.rs
use winapi::{
shared::windef::RECT,
um::winuser::{GetDesktopWindow, GetForegroundWindow, GetWindowRect},
};
<|fim_middle|>pub fn is_fullscreen() -> bool {... | code_fim | hard | {
"lang": "rust",
"repo": "bretzle/archer",
"path": "/polybar/src/util.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: bramrodenburg/delta-rs path: /rust/src/checkpoints.rs
//! Implementation for writing delta checkpoints.
use arrow::datatypes::Schema as ArrowSchema;
use arrow::error::ArrowError;
use arrow::json::reader::Decoder;
use log::*;
use parquet::arrow::ArrowWriter;
use parquet::errors::ParquetError;
us... | code_fim | hard | {
"lang": "rust",
"repo": "bramrodenburg/delta-rs",
"path": "/rust/src/checkpoints.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> let last_checkpoint_content: serde_json::Value = serde_json::to_value(&checkpoint)?;
let last_checkpoint_content = serde_json::to_string(&last_checkpoint_content)?;
info!(
"Writing _last_checkpoint to {:?}.",
self.last_checkpoint_uri
);
self... | code_fim | hard | {
"lang": "rust",
"repo": "bramrodenburg/delta-rs",
"path": "/rust/src/checkpoints.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Habu1/tonos-cli path: /src/call.rs
/*
* Copyright 2018-2020 TON DEV SOLUTIONS LTD.
*
* Licensed under the SOFTWARE EVALUATION License (the "License"); you may not use
* this file except in compliance with the License.
*
* Unless required by applicable law or agreed to in writing, software
... | code_fim | hard | {
"lang": "rust",
"repo": "Habu1/tonos-cli",
"path": "/src/call.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> println!("Calling method {} with parameters:", params.0);
println!("{}", params.1);
println!("Processing... ");
let result = ton.contracts.process_message(
msg,
Some(abi.into()),
Some(&method),
None
)
.map_err(|e| format!("Failed: {}", e.to_string())... | code_fim | hard | {
"lang": "rust",
"repo": "Habu1/tonos-cli",
"path": "/src/call.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: BarePotato/gooey path: /core/src/styles/mod.rs
pub use stylecs::{AnyStyleComponent, FallbackComponent, Style, StyleComponent};
mod alignment;
/// Types for adding a border to a widget.
pub mod border;
mod colors;
mod focus;
mod font_family;
mod font_size;
mod font_style;
mod intent;
mod lines;
... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/core/src/styles/mod.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|>ofocus, TabIndex},
font_family::FontFamily,
font_size::FontSize,
font_style::FontStyle,
intent::Intent,
lines::LineWidth,
padding::Padding,
surround::Surround,
weight::Weight,
};<|fim_prefix|>// repo: BarePotato/gooey path: /core/src/styles/mod.rs
pub use stylecs::{AnyStyl... | code_fim | hard | {
"lang": "rust",
"repo": "BarePotato/gooey",
"path": "/core/src/styles/mod.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: paritytech/ink path: /crates/ink/tests/ui/contract/pass/message-many-inputs.rs
#[ink::contract]
mod contract {
#[ink(storage)]
pub struct Contract {}
impl Contract {
#[ink(constructor)]
pub fn constructor() -> Self {
Self {}
}
#[ink(messa... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/ink",
"path": "/crates/ink/tests/ui/contract/pass/message-many-inputs.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[ink(message)]
pub fn message_5_ref(
&self,
_input_1: i8,
_input_2: i16,
_input_3: i32,
_input_4: i64,
_input_5: i128,
) {
}
#[ink(message)]
pub fn message_5_mut(
&mut self... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/ink",
"path": "/crates/ink/tests/ui/contract/pass/message-many-inputs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> #[ink(message)]
pub fn message_7_ref(
&self,
_input_1: i8,
_input_2: i16,
_input_3: i32,
_input_4: i64,
_input_5: i128,
_input_6: u8,
_input_7: u16,
) {
}
#[ink(message)... | code_fim | hard | {
"lang": "rust",
"repo": "paritytech/ink",
"path": "/crates/ink/tests/ui/contract/pass/message-many-inputs.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> {
mem.write(address, &[0xCC]) // int3
}
pub fn return_value(r: &IntRegisters) -> usize {
r.rax
}<|fim_prefix|>// repo: planet-s/strace-redox path: /src/arch/x86_64.rs
use crate::{kernel::debug, Memory};
use std::io::Result;
use syscall::data::IntRegisters;
pub fn format_syscall(mem: Option<&mut... | code_fim | medium | {
"lang": "rust",
"repo": "planet-s/strace-redox",
"path": "/src/arch/x86_64.rs",
"mode": "spm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: planet-s/strace-redox path: /src/arch/x86_64.rs
use crate::{kernel::debug, Memory};
use std::io::Result;
use syscall::data::IntRegisters;
pub fn format_syscall(mem: Option<&mut Memory>, r: &IntRegisters) -> String {
debug::format_call(mem, r.rax, r.rdi<|fim_suffix|> {
mem.write(address,... | code_fim | medium | {
"lang": "rust",
"repo": "planet-s/strace-redox",
"path": "/src/arch/x86_64.rs",
"mode": "psm",
"license": "MIT",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Data/Xml/mod.rs
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_c<|fim_suffix|> mod Dom;
#[cfg(feature = "Data_Xml_Xsl")]
pub mod Xsl;<|fim_middle|>ode, clippy::all)]
#[cfg(feature = "Data... | code_fim | easy | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Data/Xml/mod.rs",
"mode": "psm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|> mod Dom;
#[cfg(feature = "Data_Xml_Xsl")]
pub mod Xsl;<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Data/Xml/mod.rs
#![allow(unused_variables, non_upper_case_globals, non_<|fim_middle|>snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "Data... | code_fim | medium | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Data/Xml/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>ode, clippy::all)]
#[cfg(feature = "Data_Xml_Dom")]
pub mod Dom;
#[cfg(feature = "Data_Xml_Xsl")]
pub mod Xsl;<|fim_prefix|>// repo: Corallus-Caninus/windows-rs path: /src/Windows/Data/Xml/mod.rs
#![allow(unused_variables, non_upper_case_globals, non_<|fim_middle|>snake_case, unused_unsafe, non_camel_cas... | code_fim | easy | {
"lang": "rust",
"repo": "Corallus-Caninus/windows-rs",
"path": "/src/Windows/Data/Xml/mod.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_prefix|>// repo: omalaspinas/abstreet path: /map_model/src/road.rs
use crate::raw::{OriginalRoad, RestrictionType};
use crate::{osm, BusStopID, IntersectionID, LaneID, LaneType, Map, PathConstraints};
use abstutil::{Error, Warn};
use geom::{Distance, PolyLine, Polygon, Speed};
use serde::{Deserialize, Serialize}... | code_fim | hard | {
"lang": "rust",
"repo": "omalaspinas/abstreet",
"path": "/map_model/src/road.rs",
"mode": "psm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> pub fn is_backwards(&self, lane: LaneID) -> bool {
!self.dir_and_offset(lane).0
}
// lane must belong to this road. Offset 0 is the centermost lane on each side of a road, then
// it counts up from there. Returns true for the forwards direction, false for backwards.
pub fn dir... | code_fim | hard | {
"lang": "rust",
"repo": "omalaspinas/abstreet",
"path": "/map_model/src/road.rs",
"mode": "spm",
"license": "Apache-2.0",
"source": "the-stack-v2"
} |
<|fim_suffix|> match get_args(3) {
Ok(v)=>println!("Ok - {}", v), // > cargo run -- a b c d
// would get 'c'
Err(e)=>println!("Error - {}", e),
}
}
fn get_args(n:usize) -> Result<String,String> {
for (i,a) in args().enumerate() {
if i==n {
... | code_fim | hard | {
"lang": "rust",
"repo": "yc0/7daysofrust",
"path": "/day1/results/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
<|fim_suffix|>fn get_args(n:usize) -> Result<String,String> {
for (i,a) in args().enumerate() {
if i==n {
return Ok(a);
}
}
Err("Not Enough Arguments".to_string())
}<|fim_prefix|>// repo: yc0/7daysofrust path: /day1/results/src/main.rs
use std::collections::HashMap;
use std::env... | code_fim | hard | {
"lang": "rust",
"repo": "yc0/7daysofrust",
"path": "/day1/results/src/main.rs",
"mode": "spm",
"license": "unknown",
"source": "the-stack-v2"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.