blob_id stringlengths 40 40 | language stringclasses 1
value | repo_name stringlengths 5 140 | path stringlengths 5 183 | src_encoding stringclasses 6
values | length_bytes int64 12 5.32M | score float64 2.52 4.94 | int_score int64 3 5 | detected_licenses listlengths 0 47 | license_type stringclasses 2
values | text stringlengths 12 5.32M | download_success bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|
191e7d2a5852078d589762fe689dac7eacd21ec2 | Rust | decapo01/avtor-core-rs | /src/lib.rs | UTF-8 | 6,080 | 2.984375 | 3 | [] | no_license |
extern crate uuid;
#[macro_use]
extern crate validator_derive;
extern crate validator;
use validator::{Validate};
#[macro_use]
extern crate serde_derive;
extern crate serde_json;
use uuid::Uuid;
pub struct AccountId {
id: Uuid
}
pub struct Account {
pub id : AccountId
}
pub struct UserId {
pub id :... | true |
7949dd2c8377e1412f79a52d140c64d259a0d4fb | Rust | roberts-ivanovs/asteroid-wasm | /src/rust/src/programs/cube/point.rs | UTF-8 | 480 | 3.203125 | 3 | [
"MIT"
] | permissive | #[derive(Debug)]
pub struct Point3D {
x: f32,
y: f32,
z: f32,
}
impl Point3D {
pub fn new(x: f32, y: f32, z: f32) -> Self {
Self { x, y, z }
}
pub fn as_array(&self) -> [f32; 3] {
[self.x, self.y, self.z]
}
}
#[derive(Debug)]
pub struct Point2D {
x: f32,
y: f32,
}
... | true |
829dfbb0b8fb332fc7b08eeb98a63cc92dc871be | Rust | bcortier-devolutions/saphir | /src/lib.rs | UTF-8 | 2,741 | 3.109375 | 3 | [] | permissive | //! ### Saphir is a fully async-await http server framework for rust
//! The goal is to give low-level control to your web stack (as hyper does) without the time consuming task of doing everything from scratch.
//!
//! Just `use` the prelude module, and you're ready to go!
//!
//! ## Quick server setup
//! ```ignore
//... | true |
e3dfd2c960040530eaae61ab10f70eeed4be6f7f | Rust | richarddeveloper/deno_lint | /src/rules/ban_unknown_rule_code.rs | UTF-8 | 1,501 | 2.8125 | 3 | [
"MIT"
] | permissive | use super::{Context, LintRule, ProgramRef};
/// This is a dummy struct just for having the docs.
/// The actual implementation resides in [`Context`].
pub struct BanUnknownRuleCode;
impl LintRule for BanUnknownRuleCode {
fn new() -> Box<Self> {
Box::new(BanUnknownRuleCode)
}
fn tags(&self) -> &'static [&'s... | true |
f4a1c22ae149cbd10016051abc243076659bf4bf | Rust | NoraCodes/nrfind | /tests/test_sqrt.rs | UTF-8 | 781 | 2.984375 | 3 | [
"MIT"
] | permissive | #![cfg(test)]
extern crate nrfind;
use nrfind::find_sqrt;
#[test]
pub fn test_find_sqrt_fails_when_out_of_iterations() {
let radicand = 25.5;
let precision = 0.001;
let guess = 100.0; // This guess is far away on purpouse.
let iterations = 3;
find_sqrt(radicand, guess, precision, iterations).unwrap... | true |
cd924ba39ce98c21b138d463eec3cac4274c15c2 | Rust | a1phyr/assets_manager | /src/utils/tests.rs | UTF-8 | 1,961 | 3.1875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use super::*;
mod shared_bytes {
use super::SharedBytes;
#[test]
fn slice() {
let bytes = SharedBytes::from(&b"test"[..]);
assert_eq!(&*bytes, b"test");
let b2 = bytes.clone();
assert_eq!(&*b2, b"test");
assert_eq!(&*bytes, b"test");
drop(bytes);
ass... | true |
72c244b88641b8e65853ad9a33524e5ea71201b0 | Rust | dylanmckay/mri-sys | /src/ty.rs | UTF-8 | 2,274 | 2.5625 | 3 | [
"MIT"
] | permissive | #![allow(non_snake_case)]
use super::*;
use std::mem;
use libc;
/// Gets the class of a `VALUE`.
/// This is actually defined in the Ruby library, but it is inline.
/// This is a port of it.
pub unsafe fn rb_class_of(obj: VALUE) -> VALUE {
if IMMEDIATE_P(obj) {
if FIXNUM_P(obj) { return rb_cInteger; }
... | true |
bc63009b2f9a54c60eb0c54ebb959f01b63ac6ba | Rust | maximeborges/svd2rust_efm32gg990 | /src/etm/etmteevr.rs | UTF-8 | 4,588 | 2.671875 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::ETMTEEVR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
bbacc1384e692ee2bf7d1a894b6a09dfeecdb919 | Rust | houlei/QuantMath | /src/data/fixings.rs | UTF-8 | 7,415 | 3.390625 | 3 | [
"MIT"
] | permissive | use dates::Date;
use dates::datetime::DateTime;
use core::qm;
use std::collections::HashMap;
/// A fixing table is a collection of fixing curves, keyed by instrument id.
pub struct FixingTable {
fixings_known_until: Date,
fixings_by_id: HashMap<String, Fixings>
}
impl FixingTable {
/// Creates a fixing t... | true |
d93df963a1aa3eb716bef365f5e3c2f2f96e36b2 | Rust | divergentdave/aws-nitro-enclaves-acm | /src/vtok_agent/src/logger.rs | UTF-8 | 1,858 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
use std::fmt::Write;
use std::time::Instant;
use log;
use crate::config;
use crate::defs;
pub struct Logger {
timebase: Instant,
level: log::Level,
enable_timestamp: bool,
}
impl Logger {
... | true |
4c8a518073e458b34d5e9051abc5de1f973186e4 | Rust | BobIsOnFire/cli-tables-rs | /src/cells/row.rs | UTF-8 | 3,814 | 2.6875 | 3 | [] | no_license | use crate::{
borders::{Border, CellBorder, Orientation},
config::{Bound, CellConfig, Horizontal},
};
use super::{Cell, CellView, Draw, DrawCell, GridSlice, GridSliceMut};
#[derive(Debug)]
pub struct Row {
cols: Vec<Box<dyn DrawCell>>,
config: CellConfig,
}
impl Row {
pub fn new(cols: Vec<Box<dyn ... | true |
a4ead551f250a9e473b8d18e97c0f7d6f09b9ee5 | Rust | fengcen/arthas | /arthas/tests/concurrency.rs | UTF-8 | 1,604 | 2.9375 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive |
#[macro_use]
extern crate serde_derive;
#[macro_use]
extern crate arthas_derive;
extern crate rand;
extern crate arthas;
extern crate env_logger;
pub mod common;
pub mod model;
use model::*;
use std::thread::spawn;
use common::setup;
#[test]
fn test_concurrent() {
setup();
let mut threads = Vec::new();
... | true |
5415eba184884b3781f007db2e6cea732aaf1468 | Rust | Gigoteur/UnicornConsole | /unicorn/src/core/info.rs | UTF-8 | 622 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::time::Instant;
#[derive(Debug)]
pub struct Info {
pub previous_frame_time: Instant,
}
impl Info {
pub fn new() -> Info {
Info {
previous_frame_time: Instant::now(),
}
}
pub fn time(&mut self) -> u64 {
self.previous_frame_time.elapsed().as_secs()
}
... | true |
61f442273fd89c28ba96713bab9f79d67be4a895 | Rust | JonShort/rust-book-notes | /strings/src/main.rs | UTF-8 | 797 | 3.796875 | 4 | [
"MIT"
] | permissive | fn main() {
let data = "bar";
let mut empty_string = String::new();
empty_string.push_str("foo");
empty_string.push_str(data);
println!("{}", empty_string);
let mut s = data.to_string();
let ss = "initial contents".to_string();
s.push('s');
println!("{}, {}", s, ss);
let s1 = ... | true |
b43be12174dc6c84d582df5203b27ce51e6e3712 | Rust | facebook/hhvm | /hphp/hack/src/hackc/sem_diff/instr_ptr.rs | UTF-8 | 1,511 | 3.359375 | 3 | [
"PHP-3.01",
"Zend-2.0",
"MIT"
] | permissive | use std::fmt;
#[derive(Debug, Copy, Clone, Hash, Eq, PartialEq)]
pub(crate) enum InstrPtr {
None,
Index(u32),
}
impl InstrPtr {
pub(crate) fn from_usize(n: usize) -> InstrPtr {
InstrPtr::Index(n as u32)
}
pub(crate) fn as_usize(&self) -> usize {
match *self {
InstrPtr:... | true |
dcabf3c768ec0d2266228e90d1b9e0b17b096ff9 | Rust | arkada38/Rust-Design-Patterns | /src/creational/abstract_factory/launch/mod.rs | UTF-8 | 2,096 | 3.015625 | 3 | [
"MIT"
] | permissive | mod drink;
mod launch_factory;
mod main_course;
pub use drink::{BusinessDrink, CheapDrink, Drink};
pub use launch_factory::{BusinessLaunchFactory, CheapLaunchFactory, LaunchFactory};
pub use main_course::{BusinessCourse, CheapCourse, MainCourse};
pub trait Launch<M, D>
where
M: MainCourse,
D: Drink,
{
fn ... | true |
277be6bb98717bcfac9d87ee0f63136acf6a681b | Rust | JoshMcguigan/cost-of-indirection | /src/bin/enum.rs | UTF-8 | 1,521 | 3.515625 | 4 | [
"Apache-2.0"
] | permissive | use std::{env, time::Instant};
fn main() {
// I don't intend to ever set this environment variable. The purpose
// of this is only to ensure the compiler won't be able to know
// which of the two OddFinder implementations we will use.
let finder: OddFinders = match env::var("USE_FINDER_TWO") {
... | true |
a4c033dca5a7aa618a9a718201a22a9538ece458 | Rust | yyotti/euler_rust | /src/p0007.rs | UTF-8 | 647 | 2.984375 | 3 | [
"MIT"
] | permissive | //! [Problem 7](https://projecteuler.net/problem=7)([JP](http://www.odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%207))
use super::common::primes;
pub const CNT: usize = 10001;
pub fn solve(input: usize) -> i64 {
primes().skip(input - 1).next().unwrap() as i64
}
#[cfg(test)]
mod tests {
use ... | true |
ff1b8a15e8dca3151b52e404d9aae563bd80301c | Rust | skade/ferris-fencing | /src/ff_web_common/bot_hash.rs | UTF-8 | 1,061 | 3.078125 | 3 | [
"MIT",
"BSL-1.0",
"Apache-2.0"
] | permissive | use crate::bot_exe::BotExe;
use std::fmt::{self, Formatter, Display};
use blake2_rfc::blake2b::blake2b;
#[derive(Serialize, Deserialize)]
pub struct BotHash(String);
impl BotHash {
pub fn from_string(h: String) -> BotHash {
assert!(hex::decode(&h).is_ok());
assert_eq!(h.len(), 128);
BotHas... | true |
3da7de32b1b36d583cfb65bbdaa7c9a2a35d0f48 | Rust | hamadakafu/kyopro | /src/bin/typical90_2.rs | UTF-8 | 1,067 | 3.21875 | 3 | [] | no_license | use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
fn main() {
let n: usize = parse_line().unwrap();
if n % 2 == 1 {
return;
}
dfs("".to_string(), n / 2, n / 2);
}
fn dfs(now: String, leftleft: usize, rightleft: usize) {
... | true |
f8ad3a0c4a32fb540c3425a4105b02205bf9b0e9 | Rust | aquarhead/tmp-ssh-key | /src/main.rs | UTF-8 | 652 | 2.65625 | 3 | [
"MIT"
] | permissive | use std::env;
use std::fs::{self, OpenOptions};
use std::io::{self, Read, Result, Write};
use std::os::unix::fs::OpenOptionsExt;
fn main() -> Result<()> {
let mut p = env::temp_dir();
p.push("tmp-ssh-key");
let _ = fs::remove_file(&p);
let mut f = OpenOptions::new()
.write(true)
.trun... | true |
f826f035d08bc5f3fe422da776da63e0abe562a2 | Rust | haetze/DemoRust | /projects/max_sal/src/main.rs | UTF-8 | 5,912 | 3.8125 | 4 | [] | no_license | use std::cmp::Ordering;
/*
Brute force approach to maxium Salary problem.
Provided is a number of positive integers.
These are supposed to be arranged in the maxium order.
For example:
Provided: 32, 3, 5
Result: 5332
*/
fn cal(x : u32, ys : &mut Vec<u32>) -> u32 {
let mut max = x; // This... | true |
95cebf1d30dc295d9b6ddbe480fca3791126676a | Rust | cuklev/huffman-archiver-rust | /src/binary/binary_writer.rs | UTF-8 | 1,226 | 3.234375 | 3 | [
"MIT"
] | permissive | use std::io::{Write, BufWriter};
pub struct BinaryWriter<T: Write> {
buffer: u8,
index: i8,
writer: BufWriter<T>,
}
impl<T: Write> BinaryWriter<T> {
pub fn new(f: T) -> BinaryWriter<T> {
BinaryWriter {
buffer: 0,
index: 8,
writer: BufWriter::new(f),
... | true |
91ae9977d14206704ddd5d23270f6a65fe40050b | Rust | strangelovephd/minesweeper | /src/minesweeper_view.rs | UTF-8 | 4,721 | 3.046875 | 3 | [] | no_license | //! Minesweeper view.
use graphics::{
character::CharacterCache,
{Context, Graphics},
types::Color,
};
use crate::minesweeper_controller::MinesweeperController;
/// Stores Minesweeper board view settings.
pub struct MinesweeperViewSettings {
/// Position from top left corner.
pub ... | true |
796b93e91fe85cfa3d66170cf86d99cae095ed2c | Rust | mrvollger/rustybam | /src/nucfreq.rs | UTF-8 | 4,292 | 3.0625 | 3 | [] | no_license | use super::bed::*;
use rust_htslib::bam;
use rust_htslib::bam::Read;
use std::convert::TryFrom;
use std::fmt;
pub struct Nucfreq {
pub name: String,
pub pos: u32,
pub a: u64,
pub c: u64,
pub g: u64,
pub t: u64,
pub id: String,
}
impl fmt::Display for Nucfreq {
fn fmt(&self, f: &mut fmt... | true |
4e53ee668fd1b9b5b60b2798260bd7484e8c1ba4 | Rust | karakueser/ahghee | /src/main.rs | UTF-8 | 4,184 | 3.140625 | 3 | [
"Apache-2.0"
] | permissive |
extern crate protobuf;
extern crate bytes;
mod mytypes;
pub mod shard {
use std::sync::mpsc;
use std::thread;
use std::collections::BTreeMap;
use mytypes;
use std::time::Duration;
pub enum IO {
Add {nodes: mpsc::Receiver<mytypes::types::Node> },
NoOP
// add something... | true |
b7815dc57e617805b9802b56e8f0d269cb602514 | Rust | simonasker/arustid | /src/geom.rs | UTF-8 | 830 | 3 | 3 | [] | no_license | use sdl2::rect::Point;
use std::cmp;
pub fn find_limits(path: &Vec<Point>) -> (i32, i32, i32, i32) {
let mut min_x = i32::max_value();
let mut max_x = i32::min_value();
let mut min_y = i32::max_value();
let mut max_y = i32::min_value();
for &point in path {
min_x = cmp::min(min_x, point.x)... | true |
a0c0c17ed80eb3d99bbd5dffeea4e150e11ff25e | Rust | PaulFurtado/rusty_bars | /src/fftw/aligned_array.rs | UTF-8 | 3,123 | 3.25 | 3 | [] | no_license |
extern crate libc;
use self::libc::{size_t, c_void};
use std::{mem, slice};
use fftw::ext;
/// Wrapper around fftw_malloc which automatically allocates the right amount of
/// space for Rust objects, similar to calloc.
/// Returns None if allocation failed.
fn fftw_ralloc<T>(count: usize) -> Option<*mut T> {
let... | true |
cd734a1ed78465c029071304d2d40a87a2de03d8 | Rust | codejohnson/bioinformatics-compeau-pevzner | /src/dnabox.rs | UTF-8 | 3,243 | 2.921875 | 3 | [] | no_license | mod patterns;
use std::io;
use std::io::prelude::*;
fn readline()->String { io::stdin().lock().lines().next().unwrap().unwrap() }
//function to test 1A Challenge from command line
pub fn pattern_count() {
let text = readline();
let pattern = readline();
println!("{}", patterns::pattern_count(&text, &patter... | true |
574f598f76b4daa8fa61e570f915a2051dd20581 | Rust | mark3982/screeps-rust-code | /src/vec.rs | UTF-8 | 3,070 | 3.59375 | 4 | [] | no_license | /// Static sized vector. Will not automatically resize. Will panic
/// if more items than capacity are pushed and shall panic if bad
/// index is accessed.
///
/// Use DyVec for a dynamic sized vector.
use core;
use super::ffi;
use super::heap;
pub struct Vec<T> {
ptr: usize,
capacity: usize,
count: usize,
phantom... | true |
530099184f6baff872ef06adcd82bc6e3a55dab0 | Rust | whostolemyhat/learning-projects | /29-noughts-and-crosses/noughts-and-crosses/src/board.rs | UTF-8 | 4,226 | 3.734375 | 4 | [
"MIT"
] | permissive | //! Board layout and logic
use std::fmt::{ Display, Formatter, Result };
/// The states for a place on the board
#[derive(PartialEq, Clone, Debug)]
pub enum Pieces {
Player,
AI,
Empty
}
impl Display for Pieces {
fn fmt(&self, f: &mut Formatter) -> Result {
match self {
&Pieces::Pl... | true |
2a5ac7e794b09a519de4d4b487e71f8d7e365263 | Rust | dsyang/kattis | /tritiling/src/main.rs | UTF-8 | 767 | 3.078125 | 3 | [] | no_license | use std::io::{self};
use std::collections::HashMap;
fn tile(left: i64, memo: mut HashMap<i64, i64>) -> (i64, HashMap<i64, i64>) {
match memo.get(&left) {
None => {
let (a,b) = tile(left, memo);
},
Some(x) => {
}
}
return 2 + 2*tile(left - 2, memo);
}
fn main() ... | true |
ba9b8fb2889f56689edf02e4438ee1cff4db4d11 | Rust | stencila/stencila | /rust/schema-gen/src/typescript.rs | UTF-8 | 14,508 | 2.984375 | 3 | [
"Apache-2.0"
] | permissive | //! Generation of Typescript types from Stencila Schema
use std::{
collections::HashSet,
fs::read_dir,
path::{Path, PathBuf},
};
use common::{
async_recursion::async_recursion,
eyre::{bail, Context, Report, Result},
futures::future::try_join_all,
inflector::Inflector,
itertools::Iterto... | true |
2648f849ce7d7bd0e3e6ed6490399cc412b8d2cf | Rust | jakyle/rust-algos | /src/shuffle.rs | UTF-8 | 1,132 | 4.0625 | 4 | [
"MIT"
] | permissive | /// Given the array nums consisting of 2n elements in the form [x1,x2,...,xn,y1,y2,...,yn].
///
/// Return the array in the form [x1,y1,x2,y2,...,xn,yn].
///
///
/// Example 1:
///
/// Input: nums = [2,5,1,3,4,7], n = 3
/// Output: [2,3,5,4,1,7]
/// Explanation: Since x1=2, x2=5, x3=1, y1=3, y2=4, y3=7 then the answer ... | true |
8bb72a40a90ed64842ee4b42edd8586af81f8be0 | Rust | kuc-arc-f/redis_test_2_3thread | /src/main.rs | UTF-8 | 2,724 | 3.40625 | 3 | [] | no_license | // Rust + redis 書込み。3 thread並列
//
extern crate redis;
use std::env;
use std::fs::File;
use std::io::prelude::*;
use std::thread;
use std::thread::JoinHandle;
use std::time::Duration;
use redis::{Commands};
use serde::{Deserialize, Serialize};
const KEY_NAME : &str ="list_3";
//
pub fn get_content(filename: String ) -... | true |
fb8d67d610dc9d6724ea67f1a16747ffc0ab2b28 | Rust | sshravan/circ | /src/ir/term/extras.rs | UTF-8 | 5,312 | 3.28125 | 3 | [] | no_license | //! Extra algorithms over terms (e.g. substitutions)
use super::*;
use std::fmt::{self, Display, Formatter};
/// Convert `t` to width `w`, though unsigned extension or extraction
pub fn to_width(t: &Term, w: usize) -> Term {
let old_w = check(t).as_bv();
if old_w < w {
term(Op::BvUext(w - old_w), vec!... | true |
4c42bf14dbef35613c8b224b4eebf4788a5643d5 | Rust | sumeet/gen-iter | /src/lib.rs | UTF-8 | 2,950 | 4.25 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! # gen_iter - create generators to use as iterators
//!
//! `GenIter` converts a generator into an iterator over the
//! yielded type of the generator. The return type of the generator needs to be `()`.
//!
//! ```
//! #![feature(generators)]
//! #![feature(conservative_impl_trait)]
//!
//! extern crate gen_iter;
//... | true |
7ae0affe5adba3ce24b4dc7ffe533df2b8d32a52 | Rust | arranf/home-station-2 | /src/ui/pages/home/screen/widgets/weather.rs | UTF-8 | 4,613 | 2.921875 | 3 | [
"MIT"
] | permissive | use conrod_core::widget::{Canvas, Id as WidgetId, Image, Text};
use conrod_core::{color, Colorable, Positionable, Sizeable, Ui, Widget};
use lib_service_common::Weather;
use lib_ui_framework::ScreenSettingContext;
pub struct WeatherWidget {
ids: Ids,
status: Option<Weather>,
}
impl WeatherWidget {
pub fn... | true |
cedce5e00878e58eabe4049e19062da4bf1d5700 | Rust | ianhoffman/advent-of-code-2020 | /day6/src/main.rs | UTF-8 | 1,675 | 3.421875 | 3 | [] | no_license | use std::collections::HashSet;
use std::fs;
use std::iter::FromIterator;
use std::iter::Peekable;
struct Parser<I>
where
I: Iterator<Item = String>,
{
c: Peekable<I>,
}
impl<I> Parser<I>
where
I: Iterator<Item = String>,
{
fn from_iter(iter: I) -> Parser<I> {
return Parser { c: iter.peekable()... | true |
5855aa05629de84591b21d493ec852bfa5de0641 | Rust | Giovan/lumen | /examples/spawn-chain/src/elixir/chain/counter_2/label_3.rs | UTF-8 | 1,720 | 2.921875 | 3 | [
"Apache-2.0"
] | permissive | use std::convert::TryInto;
use std::sync::Arc;
use liblumen_alloc::erts::exception::system::Alloc;
use liblumen_alloc::erts::process::code::stack::frame::{Frame, Placement};
use liblumen_alloc::erts::process::{code, Process};
use liblumen_alloc::erts::term::{Boxed, Closure, Term};
pub fn place_frame_with_arguments(
... | true |
fc6423b7d1fbf7cb9f6477b82259ea7901e72e57 | Rust | Canop/broot | /src/tree/sort.rs | UTF-8 | 591 | 3.234375 | 3 | [
"MIT"
] | permissive |
/// A sort key.
/// A non None sort mode implies only one level of the tree
/// is displayed.
/// When in None mode, paths are alpha sorted
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Sort {
None,
Count,
Date,
Size,
TypeDirsFirst,
TypeDirsLast,
}
impl Sort {
pub fn prevent_deep_displ... | true |
87d199d33f786d5c4240ce3d3f60973364a2e4d6 | Rust | abusch/toyrt | /src/ray.rs | UTF-8 | 607 | 2.953125 | 3 | [] | no_license | use std::f32;
use cg::prelude::*;
use crate::{Matrix4f, Point3f, Vec3f};
#[derive(Debug, Clone)]
pub struct Ray {
pub o: Point3f,
pub d: Vec3f,
pub t_max: f32,
}
impl Ray {
pub fn new(o: Point3f, d: Vec3f) -> Self {
Ray {
o,
d,
t_max: f32::INFINITY,
... | true |
2575650d85ab9d360d33ceecbb11e5f1abde368c | Rust | bdalrhm/rmc | /src/test/cbmc/Transparent/transparent2.rs | UTF-8 | 811 | 3.078125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-other-permissive",
"LicenseRef-scancode-unknown-license-reference",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT
#[derive(Clone, Copy)]
struct Target {
x: u32,
y: u32,
}
struct Container<T> {
ptr: std::ptr::NonNull<T>,
}
impl<T> Container<T>
where
T: Copy,
{
fn new(val: &mut T) -> Self {
... | true |
e29e450b80883000bfa979633c1817550783d57c | Rust | 0xack13/recalc | /src/main.rs | UTF-8 | 5,459 | 3.125 | 3 | [] | no_license | mod ast;
mod parser;
use std::collections::HashMap;
use ast::{Node, Op};
use parser::Parser;
use rustyline::Editor;
struct Context {
precision: Option<usize>,
vars: HashMap<String, Node>,
}
fn apply_op(op: Op, a: f64, b: f64) -> f64 {
match op {
Op::Add => a + b,
Op::Subtract => a - b,
... | true |
bc0bcb01be32c9aadd2b80b80284c0a7981c5498 | Rust | microcluster/devand | /devand-web/src/state/code_now.rs | UTF-8 | 2,042 | 2.8125 | 3 | [
"Apache-2.0"
] | permissive | use devand_core::{CodeNowUsers, PublicUserProfile, User, UserId};
use std::collections::BTreeMap;
use std::time::{Duration, Instant};
#[derive(Clone)]
pub struct CodeNowUsersMap {
users: BTreeMap<UserId, (Instant, PublicUserProfile)>,
last_clear: Instant,
}
impl Default for CodeNowUsersMap {
fn default() ... | true |
6a7155a15c2a1be6fe601a198f05c574c14bf36b | Rust | kubabialy/rust-snake | /src/main.rs | UTF-8 | 1,170 | 3.453125 | 3 | [] | no_license | mod board;
use std::io;
fn main() {
let (width, height) = fetch_dimesnions();
let board = board::create_board(width, height);
board.print_self();
}
/**
* Grabs dimensions of the board from the user
* and then tries to convert that into u32 types
* required by Board struct
*/
fn fetch_dimesnions() -... | true |
57900ca93063319f981475b56de1f15705e2caa4 | Rust | oxidecomputer/third-party-api-clients | /github/src/secret_scanning.rs | UTF-8 | 8,750 | 3.046875 | 3 | [
"MIT",
"LicenseRef-scancode-unknown"
] | permissive | use crate::Client;
use crate::ClientResult;
pub struct SecretScanning {
pub client: Client,
}
impl SecretScanning {
#[doc(hidden)]
pub fn new(client: Client) -> Self {
SecretScanning { client }
}
/**
* List secret scanning alerts for a repository.
*
* This function performs... | true |
6501c4b9f7eabf8138de39ff38b1a68cf44c291e | Rust | mark-inderhees/aoc | /rust/src/utils/tetris.rs | UTF-8 | 9,461 | 3.53125 | 4 | [
"MIT"
] | permissive | use std::vec;
use strum_macros::EnumIter;
use crate::utils::board::*;
/// A game of tetris. It is played on a grid with a couple of shape types.
/// Moves are down, left, right. Rotation is not supported.
/// A collison will prevent shape from moving.
/// The board grows infinitely tall.
/// Shapes start a configurab... | true |
67f4eb7b0f2312ce198c71f9c2c412bfb5535cdb | Rust | quodlibetor/tabin | /turbine-plugins/src/bin/check-fs-writeable.rs | UTF-8 | 3,311 | 3.421875 | 3 | [] | no_license | //! Check that we can write to disk
extern crate rustc_serialize;
extern crate docopt;
use std::error::Error;
use std::fs;
use std::io::Write;
use std::io::ErrorKind;
use std::thread;
use std::path::Path;
use std::process;
use std::sync::mpsc::channel;
use docopt::Docopt;
static USAGE: &'static str = "
Usage:
c... | true |
4a3e30c2eca937e7cc97579a5f561c7dd3a27f2a | Rust | CodeChain-io/intertrait | /src/hasher.rs | UTF-8 | 805 | 2.90625 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::convert::TryInto;
use std::hash::{BuildHasherDefault, Hasher};
use std::mem::size_of;
/// A simple `Hasher` implementation tuned for performance.
#[derive(Default)]
pub struct FastHasher(u64);
/// A `BuildHasher` for `FastHasher`.
pub type BuildFastHasher = BuildHasherDefault<FastHasher>;
impl Hasher for Fa... | true |
73b11eca8ef89c77afacbb799c40aefe1808687a | Rust | marco-c/gecko-dev-wordified-and-comments-removed | /third_party/rust/syn-1.0.107/src/group.rs | UTF-8 | 3,761 | 2.59375 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0",
"MIT"
] | permissive | use
crate
:
:
error
:
:
Result
;
use
crate
:
:
parse
:
:
ParseBuffer
;
use
crate
:
:
token
;
use
proc_macro2
:
:
{
Delimiter
Span
}
;
#
[
doc
(
hidden
)
]
pub
struct
Parens
<
'
a
>
{
pub
token
:
token
:
:
Paren
pub
content
:
ParseBuffer
<
'
a
>
}
#
[
doc
(
hidden
)
]
pub
struct
Braces
<
'
a
>
{
pub
token
:
token
:
:
Br... | true |
2c82770dc4f3e0f34e6a0bc920f8d3c96e17aacd | Rust | chrisduerr/leechbar-bin | /src/workspace_component.rs | UTF-8 | 3,246 | 2.59375 | 3 | [] | no_license | use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::mpsc::Receiver;
use image_cache::ImageCache;
use std::sync::{Arc, Mutex};
use std::process::Command;
use std::path::Path;
use i3::I3Change;
use leechbar::*;
use std::thread;
use chan;
pub struct Workspace {
id: i32,
image_cache: ImageCache,
visi... | true |
52ca73b044c1354fe88ba057f5c67c6f06489bca | Rust | Aminatak/RustBigProjet2-srh | /src/shell/parser/commands/mod.rs | UTF-8 | 938 | 3.5625 | 4 | [] | no_license | use std::fmt;
/// Init struct to model one Command
#[derive(Clone, Debug)]
pub struct Command{
pub command_name: String,
pub command_args: Vec<String>
}
impl fmt::Display for Command {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut args : String = String::from("");
for i... | true |
a09141ba12a96ae758b825695277f6d8e1ce5924 | Rust | UmerMIB/Rust-Basic-Examples | /Structs/src/main.rs | UTF-8 | 1,113 | 3.859375 | 4 | [] | no_license | /*Create a struct(named student) with 2 fields( roll no, name ) , impl this struct with 1 method that show
details of struct, create 1 method to change the value one of the field of struct , 1 associated function
that return an instance of that structure . Use all these functions and methods in main function*/
stru... | true |
6c61985ad8add466c802de93eba4fb767de9fa10 | Rust | Meeji/RustyECS | /src/ecs/container.rs | UTF-8 | 2,572 | 2.65625 | 3 | [
"Apache-2.0"
] | permissive | #![macro_use]
pub trait FromEcs<E: ContainsSystem> where Self: Sized {
fn from_ecs(ecs: &E) -> &Self;
}
pub trait FromEcsMut<E: ContainsMutSystem>: FromEcs<E> {
fn from_ecs_mut(ecs: &mut E) -> &mut Self;
}
pub trait ContainsSystem where Self: Sized {
fn get_system<S>(&self) -> &S
where S: FromEcs... | true |
423a722993efa78b71ec08d010995a2f0d7a237f | Rust | kieranelby/AoC2020Rust | /day10/src/main.rs | UTF-8 | 1,675 | 3.171875 | 3 | [] | no_license | use std::collections::HashMap;
fn main() {
let content = std::fs::read_to_string("input.txt").expect("could not read file");
let mut adapters: Vec<i32> = content.lines().map(|l| l.parse().unwrap()).collect();
adapters.sort();
println!("adapters = {:?}", adapters);
let mut differences = Vec::new();
... | true |
44bf0a06ca3cd389669ac2da4e606e30101bcb0d | Rust | riboseinc/rust-nereon | /derive/src/lib.rs | UTF-8 | 7,105 | 2.703125 | 3 | [] | no_license | // Copyright (c) 2018, [Ribose Inc](https://www.ribose.com).
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditio... | true |
33aa5e879088c26776d0f8b0f034f51a2682b927 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/cstr/src/parse.rs | UTF-8 | 6,852 | 2.6875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | use
crate
:
:
Error
;
use
proc_macro2
:
:
{
Delimiter
Ident
Literal
Span
TokenStream
TokenTree
}
;
use
std
:
:
char
;
macro_rules
!
unexpected_content
{
(
)
=
>
{
"
expected
one
of
:
byte
string
literal
string
literal
identifier
"
}
;
}
pub
(
crate
)
fn
parse_input
(
mut
input
:
TokenStream
)
-
>
Result
<
(
Vec
<
u8
>
... | true |
5e52249a94476ea02a1b3e380f373abf4b4237fe | Rust | alfredchavez/edgeCloudOsmotic | /dockerVersion/sieve/src/main.rs | UTF-8 | 894 | 3.328125 | 3 | [] | no_license | use structopt::StructOpt;
#[derive(Debug, StructOpt)]
struct Opt {
/// Evaluate HQ9+ source code
#[structopt(short = "e", long = "eval")]
source_code: Option<String>,
}
fn simple_sieve(limit: usize) -> usize {
let mut is_prime = vec![true; limit + 1];
is_prime[0] = false;
if limit >= 1 { is_pr... | true |
9e9eaa10c3b640b07deb40bcd18addf34454e2f8 | Rust | rick68/rust-trace | /libcore/simd/stuct_i64x2/shr.rs | UTF-8 | 681 | 2.921875 | 3 | [
"MIT"
] | permissive | #![feature(core, core_simd)]
extern crate core;
#[cfg(test)]
mod tests {
use core::simd::i64x2;
// #[simd]
// #[derive(Copy, Clone, Debug)]
// #[repr(C)]
// pub struct i64x2(pub i64, pub i64);
#[test]
fn shr_test1() {
let x: i64x2 = i64x2(
0, 1
);
let y: i64x2 = i64x2(
2, 2... | true |
87d51a75fc59a2feb15bd9671569643fff97d6d0 | Rust | marco-c/gecko-dev-wordified | /third_party/rust/hyper/src/body/mod.rs | UTF-8 | 2,407 | 2.625 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | /
/
!
Streaming
bodies
for
Requests
and
Responses
/
/
!
/
/
!
For
both
[
Clients
]
(
crate
:
:
client
)
and
[
Servers
]
(
crate
:
:
server
)
requests
and
/
/
!
responses
use
streaming
bodies
instead
of
complete
buffering
.
This
/
/
!
allows
applications
to
not
use
memory
they
don
'
t
need
and
allows
exerting
/
/
!
back... | true |
934c44b6234bab6ca3077dabc525c04b253647a4 | Rust | skyne98/rgx | /src/error.rs | UTF-8 | 730 | 2.8125 | 3 | [
"MIT"
] | permissive | use std::error;
use std::fmt;
use std::io;
#[derive(Debug, Copy, Clone)]
pub enum Error {
NoAdaptersFound,
}
impl From<Error> for io::Error {
fn from(err: Error) -> io::Error {
io::Error::new(io::ErrorKind::Other, err)
}
}
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>... | true |
2c27d35a2edb888b05c773d3722257042f907842 | Rust | bevyengine/bevy | /crates/bevy_hierarchy/src/valid_parent_check_plugin.rs | UTF-8 | 3,532 | 3 | 3 | [
"Apache-2.0",
"MIT",
"Zlib",
"LicenseRef-scancode-free-unknown",
"LicenseRef-scancode-unknown-license-reference",
"LicenseRef-scancode-other-permissive"
] | permissive | use std::marker::PhantomData;
use bevy_app::{App, Last, Plugin};
use bevy_core::Name;
use bevy_ecs::prelude::*;
use bevy_log::warn;
use bevy_utils::{get_short_name, HashSet};
use crate::Parent;
/// When enabled, runs [`check_hierarchy_component_has_valid_parent<T>`].
///
/// This resource is added by [`ValidParentCh... | true |
4398418a92f60aad28e2957ad30f95e3c2b51075 | Rust | domstrueboy/courses | /exercism-rust/rust/raindrops/src/lib.rs | UTF-8 | 320 | 2.90625 | 3 | [] | no_license | pub fn raindrops(n: u32) -> String {
let mut drops = vec![];
let map = vec![(3, "Pling"), (5, "Plang"), (7, "Plong")];
for (factor, drop) in map {
if n % factor == 0 {
drops.push(drop);
}
}
if drops.len() == 0 {
return n.to_string();
}
drops.join("")
}
| true |
57589aaedbba01902362a0b1c4741f439a4fd05b | Rust | LU15W1R7H/joy | /basics/src/basic.rs | UTF-8 | 25,937 | 3.75 | 4 | [] | no_license |
#[test]
fn basics() {
let immutable = 5;
let mut mutable = 6;
mutable = 2;
let spaces = " "; // auto type deduction
let spaces = spaces.len(); // "shadowing" new variable with same name
const CONSTANT: u32 = 100_000; // constant (type must be specified)
let tuple: (i32, f64, u8) = (5... | true |
350affc89123d119290bb265742b0898efe4056f | Rust | starlingjs/starling | /src/promise_future_glue.rs | UTF-8 | 15,072 | 3.34375 | 3 | [
"Apache-2.0"
] | permissive | //! Gluing Rust's `Future` and JavaScript's `Promise` together.
//!
//! JavaScript's `Promise` and Rust's `Future` are two abstractions with the
//! same goal: asynchronous programming with eventual values. Both `Promise`s
//! and `Future`s represent a value that may or may not have been computed
//! yet. However, the ... | true |
413fe5e0e8d0ccc0300a6f0353b8bea3ba50a39b | Rust | sampersand/quest-old | /rust/src/env/builtins.rs | UTF-8 | 2,782 | 2.625 | 3 | [] | no_license | use lazy_static::lazy_static;
use crate::{Object, Error, Environment};
use std::io::{self, Write, Read};
// to make it easier on my eyes
macro_rules! builtins {
($($args:tt)*) => {
lazy_static! {
pub static ref BUILTINS_MAP: Object = Object::new(crate::collections::ParentalMap::new_mapped(
|| crate::object:... | true |
ec21e18ca5b7ec7ef869a6da009c1969fb868eab | Rust | COLDTURNIP/raphanus_leetcode | /rust/src/p49.rs | UTF-8 | 2,610 | 3.65625 | 4 | [] | no_license | /*
Problem 21. Merge Two Sorted Lists
==================================
https://leetcode.com/problems/group-anagrams/
Given an array of strings strs, group the anagrams together. You can return the answer in any order.
An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase,
t... | true |
14e6ad7d51f75674a9b6cbd59ad9c9beeece49fe | Rust | michbuett/arena-rl | /src/ui/input.rs | UTF-8 | 1,917 | 2.59375 | 3 | [
"MIT"
] | permissive | use sdl2::rect::{Rect, Point};
use sdl2::event::Event as Sdl2Event;
use sdl2::keyboard::Keycode;
use sdl2::EventPump;
use crate::core::*;
use crate::ui::{ClickArea, ClickAreas, ScreenPos, UI};
pub fn poll(sdl_events: &mut EventPump, click_areas: &ClickAreas, ui: &UI) -> Option<UserInput> {
for event in sdl_events... | true |
edb59fb9705e14789735791c6b34d83b4e2ebdca | Rust | prisma/prisma-engines | /query-engine/connector-test-kit-rs/query-engine-tests/tests/writes/nested_mutations/already_converted/nested_create_inside_update.rs | UTF-8 | 14,322 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | use query_engine_tests::*;
//TODO: which tests to keep and which ones to delete???? Some do not really test the compound unique functionality
// TODO(dom): All failing except one
#[test_suite]
mod create_inside_update {
use query_engine_tests::{assert_error, run_query, run_query_json, DatamodelWithParams};
use... | true |
f51b8722bff471dcc4c722be735fc2687fb98d06 | Rust | Yasu-umi/sudachiclone-rs | /src/plugin/prolonged_soundmark_input_text_plugin.rs | UTF-8 | 7,124 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | use std::collections::HashSet;
use serde_json::Value;
use super::input_text_plugin::{InputTextPluginReplaceErr, RewriteInputText};
use crate::utf8_input_text_builder::UTF8InputTextBuilder;
#[derive(Debug)]
pub struct ProlongedSoundMarkInputTextPlugin {
psm_set: HashSet<u32>,
replace_symbol: String,
}
impl Rewri... | true |
3ca6447bef36c06cdabe22545773d7c8cce08cdf | Rust | wezm/cc2650 | /src/flash/boundary.rs | UTF-8 | 23,287 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::BOUNDARY {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w ... | true |
46b2372bf2683ded1c894565a7c0ea4bd20a4b18 | Rust | jaemk/misc | /daily_programmer/reverse_factorial/rust_refact/src/lib.rs | UTF-8 | 442 | 3.390625 | 3 | [] | no_license | pub fn refact(fac: &i32) -> Option<i32> {
let mut div: i32 = 2;
let mut val: i32 = *fac;
while val % div == 0 {
val = val / div;
div += 1;
}
if val == 1 {
Some(div - 1)
} else {
None
}
}
pub fn reverse_factorial(n: &i32) -> String {
let val = match refact(... | true |
ed128c0b8b9cc3598f0235a3a7d5acc57e5db072 | Rust | KuangjuX/FAT32 | /src/block_cache.rs | UTF-8 | 5,877 | 2.65625 | 3 | [
"MIT"
] | permissive | use super::{BlockDevice, BLOCK_SZ};
use alloc::collections::VecDeque;
use alloc::sync::Arc;
use lazy_static::*;
use spin::RwLock;
#[allow(unused)]
// use riscv::register::time;
pub struct BlockCache {
pub cache: [u8; BLOCK_SZ],
block_id: usize,
block_device: Arc<dyn BlockDevice>,
modified: bool,
#[... | true |
d4dbf8a821815c8820f39553e5e4b4cf217e73e2 | Rust | facundoolano/exercism | /rust/bracket-push/src/lib.rs | UTF-8 | 503 | 3.578125 | 4 | [] | no_license | pub fn brackets_are_balanced(string: &str) -> bool {
let mut pairs = Vec::<char>::new();
for c in string.chars() {
match (pairs.last(), c) {
(Some('{'), '}') | (Some('['), ']') | (Some('('), ')') => {
pairs.pop();
}
(_, _) if is_bracket(c) => {
... | true |
ab667167d5cce7851944d92b209c4f2008a3650d | Rust | steveklabnik/build-example | /xtask/src/main.rs | UTF-8 | 1,396 | 2.984375 | 3 | [] | no_license | use std::env;
use std::process::Command;
fn main() {
// sorry for my crimes in advance, this is an example
let mut args = env::args();
args.next();
match &*args.next().unwrap() {
"binary-v7" => v7(),
"binary-v8" => v8(),
_ => println!("don't understand"),
}
}
fn v7() {
... | true |
8729761a4bc06f1465f9d42534a00b156634e619 | Rust | salsa-rs/salsa | /salsa-2022-tests/tests/tracked_fn_constant.rs | UTF-8 | 547 | 2.9375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Test that a constant `tracked` fn (has no inputs)
//! compiles and executes successfully.
#![allow(warnings)]
#[salsa::jar(db = Db)]
struct Jar(tracked_fn);
trait Db: salsa::DbWithJar<Jar> {}
#[salsa::tracked]
fn tracked_fn(db: &dyn Db) -> u32 {
44
}
#[test]
fn execute() {
#[salsa::db(Jar)]
#[derive... | true |
2482f76a63651084b1ab749e520325a71ed6daa1 | Rust | mathieu-lemay/aoc-2020 | /d13/src/main.rs | UTF-8 | 3,848 | 3.125 | 3 | [
"MIT"
] | permissive | use num::integer::lcm;
use std::fmt::Display;
use std::time::Instant;
use aoc_2020::get_input;
#[derive(Debug)]
struct Bus {
number: u64,
offset: u64,
}
fn parse(input: &[String]) -> (u64, Vec<Bus>) {
let ts = input[0].parse().unwrap();
let buses = input[1]
.split(',')
.enumerate()
... | true |
88423e649ec57dac2b937204e3a88deaf19138d3 | Rust | mesalock-linux/crates-sgx | /vendor/heapsize/build.rs | UTF-8 | 1,331 | 2.546875 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::env::var;
use std::process::Command;
use std::str;
fn main() {
let verbose = Command::new(var("RUSTC").unwrap_or("rustc".into()))
.arg("--version")
.arg("--verbose")
.output()
.unwrap()
.stdout;
let verbose = str::from_utf8(&verbose).unwrap();
let mut commit... | true |
8908e9cd155b6a3856ab747552f71c16458716d5 | Rust | nwin/rust-jpeg | /src/lib.rs | UTF-8 | 2,211 | 2.828125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! JPEG decoder
//!
// Credits go to stb_image and jpeg.go for being a reference implementation
// and to stb_image for lending some code.
mod dct;
mod decoder;
mod huffman;
mod util;
pub use decoder::Decoder;
#[derive(Debug)]
/// Available JPEG marker
enum Marker {
// Start Of Frame markers
/// Start Of Frame... | true |
b774930ebbcff92dc4f56a2599c0f9eea2670335 | Rust | 12101111/fbterm | /src/font/truetype.rs | UTF-8 | 2,989 | 2.828125 | 3 | [
"MIT"
] | permissive | use super::{Cow, Font, Glyph, Point};
use alloc::sync::Arc;
pub struct TrueTypeFont {
inner: fontdue::Font,
cache: lru::LruCache<char, Glyph>,
line_size: usize,
height: usize,
size: f32,
}
impl TrueTypeFont {
pub fn new(data: &[u8], size: f32) -> TrueTypeFont {
let settings = fontdue::... | true |
f15f96ef0274637f762965293db2b45e0cdf37f1 | Rust | abiriadev/threads | /src/main.rs | UTF-8 | 1,660 | 2.84375 | 3 | [] | no_license | // mod th
// use std::process;
use std::any;
use std::sync::mpsc;
use std::thread::JoinHandle;
use std::time::Duration;
use std::{process, thread};
// use std::any::Any;
fn main() {
let v = vec![1, 2, 3];
let (tx, rx) = mpsc::channel();
let tx1 = mpsc::Sender::clone(&tx);
let handle: JoinHandle<()> ... | true |
04b644ae65a2a6e824eed43f8f3f3d1a535126db | Rust | F3kilo/settings_path | /src/lib.rs | UTF-8 | 1,419 | 3.3125 | 3 | [] | no_license | use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::io::ErrorKind;
use std::path::PathBuf;
#[derive(Debug)]
pub enum FindPathError {
Io(std::io::Error),
Var(std::env::VarError),
}
impl std::error::Error for FindPathError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static... | true |
2dffec04869078f9fcae44983b1f9bb772d0444d | Rust | Steelbirdy/dnd_5etools_rs | /api/src/util/copy.rs | UTF-8 | 2,740 | 2.765625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use serde_json::Value;
use serde_with::skip_serializing_none;
use std::collections::HashMap;
#[skip_serializing_none]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct CopyBlock<'a> {
pub name: &'a str,
pub source: &'a str,
/// Used in deity data
... | true |
a0bb2fb1679e2b50e8a5aa5957e7f06ae1628de1 | Rust | kodsnack/advent_of_code_2019 | /johan-oelrich-rust/day09/src/b.rs | UTF-8 | 359 | 2.578125 | 3 | [
"Apache-2.0"
] | permissive | pub fn run() -> String {
let program = loader::load_integer_row_list("input.csv")[0].clone();
let mut computer = icc::Computer::load(0, &program);
let result = icc::run_to_end(&mut computer, &[2]);
match result {
Ok(data) => format! {"{:?}", data},
Err(error) => error,
}
}
#[cfg(test)]
mod test {
#[... | true |
7dc83a47e0cb1986297b295a8684f448e5058005 | Rust | tbergqvist/hero_rpg | /server/src/gui_item.rs | UTF-8 | 1,813 | 3.296875 | 3 | [
"MIT"
] | permissive | use serde;
use serde::ser::SerializeStruct;
use http_method::HttpMethod;
pub enum GuiItem {
Text{value: String},
Form{name: String, method: HttpMethod, link: String, fields: Vec<FieldItem> },
}
pub enum FieldItem {
TextInput{ name: String, value: Option<String> },
}
impl serde::Serialize for GuiItem {
fn ser... | true |
09a194315c00f1ffa8c93fa2e0225add25eaaabb | Rust | fabianbadoi/rusty-pine | /libs/src/integration_tests.rs | UTF-8 | 6,638 | 2.765625 | 3 | [] | no_license | //! Integration/end-to-end tests for the transpilation process
static TEST_SPECS: &str = r#"
humans | s: name | preferences
==============================
SELECT humans.name, preferences.*
FROM preferences
LEFT JOIN humans ON humans.id = preferences.humanId
LIMIT 10
humans | s: id isBlue
... | true |
1fa3b549afb13d7c83d90c5af594dcebcdf5b877 | Rust | schultyy/HoneyBadger | /tests/codegen_test.rs | UTF-8 | 1,124 | 2.890625 | 3 | [] | no_license | #[path="../src/grammar.rs"]
mod grammar;
#[path="../src/parser.rs"]
mod parser;
#[path="../src/codegen.rs"]
mod codegen;
#[path="../src/lexicon.rs"]
mod lexicon;
#[path="../src/tokenizer.rs"]
mod tokenizer;
#[path="../src/transformer.rs"]
mod transformer;
fn output_program(input_program: &str) -> Result<String, Vec<St... | true |
5c2c0c64adabf8f7090471802bf3812c97a8a550 | Rust | twe4ked/nushell | /src/commands/where_.rs | UTF-8 | 917 | 2.703125 | 3 | [] | no_license | use crate::errors::ShellError;
use crate::object::base::find;
use crate::prelude::*;
pub fn r#where(args: CommandArgs) -> Result<OutputStream, ShellError> {
if args.args.is_empty() {
return Err(ShellError::string("select requires a field"));
}
let field: Result<String, _> = args.args[0].as_string(... | true |
669d2c87bf975580d1f4275dbc3060423b737dcf | Rust | smol-rs/smol | /examples/async-h1-server.rs | UTF-8 | 3,276 | 3.28125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! An HTTP+TLS server based on `async-h1` and `async-native-tls`.
//!
//! Run with:
//!
//! ```
//! cargo run --example async-h1-server
//! ```
//!
//! Open in the browser any of these addresses:
//!
//! - http://localhost:8000/
//! - https://localhost:8001/ (accept the security prompt in the browser)
//!
//! Refer to... | true |
e6e5ab4d638cce6cd8034d356c65e87a3d5e70ad | Rust | simon-mo/nara | /src/main.rs | UTF-8 | 2,829 | 2.65625 | 3 | [] | no_license | use structopt::StructOpt;
use tokio::runtime::Runtime;
use tokio::sync::oneshot;
use tokio::task::JoinHandle;
use nara_core::bencher::Bencher;
use nara_core::reporter::Reporter;
use nara_core::server::Server;
#[derive(Debug, StructOpt)]
#[structopt(name = "nara", about = "Profiler for HTTP and Python Services.")]
s... | true |
ef7d50f0d98a73c44a2ce795a4a8bd00b4049a9f | Rust | magiruuvelvet/gentoo-portage-config | /unittests/rust-test/test.rs | UTF-8 | 676 | 2.625 | 3 | [] | no_license | use std::env;
// test if rustc forced against libunwind instead of libgcc_s
// passes a simple example application
// $ rustc test.rs
// $ ldd test
// should contain libunwind by default
// application should work too without crashing
// rust-bin uses libgcc_s but a symlink to libunwind inside
// /opt/rust-bin-$VERSI... | true |
a717a221b5f4e23a2d86edce32c27e63ebeb18ed | Rust | mangolang/cli | /src/common/util/os/ps_windows.rs | UTF-8 | 354 | 2.75 | 3 | [
"Apache-2.0"
] | permissive |
pub fn kill_process(pid: u32) {
//TODO @mark:
eprintln!("mango cannot kill processes on this OS; please kill process {} yourself", pid);
}
pub fn is_process_alive(pid: u32) -> bool {
//TODO @mark:
eprintln!("mango cannot determine which processes are running on this OS; it will be assumed that process... | true |
f2d3145d2d1150418f85d0dacefdf5be2df64235 | Rust | ltriess/advent-of-code-2020 | /src/bin/03_toboggan-trajectory_part1.rs | UTF-8 | 485 | 3.078125 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io::{self, BufRead, BufReader};
fn main() -> io::Result<()> {
let f = File::open("data/03_input.txt")?;
let f = BufReader::new(f);
let mut index = 0;
let mut counter = 0;
for line in f.lines() {
let s = line.unwrap();
let tree = s.chars().nth(index).unw... | true |
e0bbe61d6b00f0a8771f581bff047608eb5ba9f8 | Rust | ShashankaNataraj/Juggernaut | /src/dir/mod.rs | UTF-8 | 3,392 | 3.046875 | 3 | [
"MIT"
] | permissive | mod utils;
use utils::get_dir_name_from_path;
use std::fs::metadata;
use ignore::Walk;
use std::fs;
extern crate dirs;
use fs::File;
use std::io::Write;
use std::path::Path;
use std::path::PathBuf;
use crate::file;
#[derive(Serialize)]
pub struct DiskEntry {
path: String,
is_dir: bool,
name: String,
}
fn... | true |
0251373c2d8b917b9595b0e5488aef128932721b | Rust | innerr/tikv | /components/engine_traits/src/errors.rs | UTF-8 | 2,801 | 2.71875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2019 TiKV Project Authors. Licensed under Apache-2.0.
use error_code::{self, ErrorCode, ErrorCodeExt};
use raft::{Error as RaftError, StorageError};
use std::{error, result};
quick_error! {
#[derive(Debug)]
pub enum Error {
// Engine uses plain string as the error.
Engine(msg: Str... | true |
f941f0be2cc49d6f00e777c176297fdb7a359b0f | Rust | ironhaven/dreadbot | /src/card.rs | UTF-8 | 1,605 | 4.125 | 4 | [] | no_license | pub type Cents = u32;
pub fn format_cents(amount: Cents) -> String {
let dollars = amount / 100;
let remainder = amount % 100;
format!("{}.{:02}", dollars, remainder)
}
#[derive(Debug)]
pub struct Card {
pub quantity: u32,
pub name: String,
pub price: Option<Cents>
}
impl Card {
pub fn from_goldfish_l... | true |
b7fe99129b27c5055ce215cf411a302b9fdbe574 | Rust | thomashk0/advent-of-code | /2019/rust/src/day11.rs | UTF-8 | 3,523 | 3.0625 | 3 | [] | no_license | use crate::intcode::{load_tape, HaltCause, IntCpu};
use std::collections::HashMap;
use std::io;
type Vec2 = (i64, i64);
fn rotr90(p: Vec2) -> Vec2 {
(p.1, -p.0)
}
fn rotl90(p: Vec2) -> Vec2 {
(-p.1, p.0)
}
fn vec_add(p: Vec2, q: Vec2) -> Vec2 {
(p.0 + q.0, p.1 + q.1)
}
pub fn limits(world: &HashMap<Vec... | true |
b9982609c256b1aea95130efcdeb1b3f5eabc361 | Rust | clayboone/rust-learning | /4.0-ownership/src/main.rs | UTF-8 | 4,215 | 4.125 | 4 | [] | no_license | fn main() {
let s = String::from("hello");
takes_ownership(s);
// s is not usable because ownership was passed and wasn't given back?
let x = 5;
makes_copy(x);
// x is still usable because a uint32_t has a known size at compile time
// and is Copy (trait). it sits on the stack and no pe... | true |
a76c6488b0bb6e32fd8ff87b486f059a0e08d7b5 | Rust | JRAndreassen/graph-rs | /examples/rocket_example_with_state.rs | UTF-8 | 4,484 | 2.890625 | 3 | [
"MIT"
] | permissive | #![feature(proc_macro_hygiene, decl_macro)]
#![feature(plugin)]
#[macro_use]
extern crate rocket;
#[allow(unused_imports)]
#[macro_use]
extern crate serde_json;
extern crate reqwest;
use from_as::*;
use graph_rs::oauth::OAuth;
use rocket::http::RawStr;
use rocket_codegen::routes;
use std::thread;
use std::time::Durati... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.