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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
3492dbbd2ccb6ddf461ace22c29becfdf23c6109 | Rust | ellipticoin/serde_cose | /tests/serde_cose_test.rs | UTF-8 | 1,687 | 2.703125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | mod common;
use common::EXAMPLES_DIR;
use serde::Deserialize;
use serde_cose::{self, Curve, KeyType};
use std::fs::read_to_string;
#[derive(Deserialize, Debug)]
struct Test {
input: Input,
output: Output,
}
#[derive(Deserialize, Debug)]
struct Input {
plaintext: String,
sign0: Sign0,
}
#[derive(Deseria... | true |
6cf0db256fec95dbdbe2d60d76e5f4e6ca7a8bde | Rust | danieldulaney/xkcdfs | /src/requests/database.rs | UTF-8 | 6,442 | 2.734375 | 3 | [
"MIT"
] | permissive | use rusqlite::{ToSql, NO_PARAMS};
use std::convert::TryInto;
use crate::Comic;
pub fn setup(conn: &rusqlite::Connection) -> rusqlite::Result<()> {
info!("Setting up database");
conn.execute(
r"
CREATE TABLE IF NOT EXISTS comics (
num INTEGER PRIMARY KEY,
day INTEGER,
... | true |
76ca35108b7a0ddbb34cd6ba0b1b2b1a6ad6dfb5 | Rust | 0xflotus/crossterm | /crossterm_input/src/input/unix_input.rs | UTF-8 | 4,648 | 3.078125 | 3 | [
"MIT"
] | permissive | //! This is a UNIX specific implementation for input related action.
use super::*;
use crate::sys::unix::{get_tty, read_char_raw};
use crossterm_utils::{csi, write_cout, Result};
use std::char;
use std::io::{Read, Write};
pub struct UnixInput;
impl UnixInput {
pub fn new() -> UnixInput {
UnixInput {}
... | true |
f62a966f2c974e85c5f5839a7645c9030ccc235f | Rust | Haggus/polliquad | /src/main.rs | UTF-8 | 1,793 | 2.625 | 3 | [
"MIT"
] | permissive | extern crate sfml;
use sfml::window::{ContextSettings, VideoMode, event, Close, keyboard};
use sfml::graphics::{RenderWindow, RenderTarget, Color, Font, Text};
use sfml::system::{Clock, Vector2f};
mod tile;
mod level;
mod map;
use level::{Level};
fn main() {
let mut window = RenderWindow::new(VideoMode::new_ini... | true |
a53e6570508c207d0042ac5bdad75a5093077580 | Rust | weidonglian/rust-playground | /tests/reactangle_test.rs | UTF-8 | 171 | 2.9375 | 3 | [
"MIT"
] | permissive | use rust_playground::rectangle::Rectangle;
#[test]
fn can_hold() {
let a = Rectangle::new(24, 50);
let b = Rectangle::new(10, 20);
assert!(a.can_hold(&b));
}
| true |
312d0bfc51d760497dee37441041b1b5151c9e54 | Rust | julesartd/Exercices-Kattis | /fizzbuzz/src/main.rs | UTF-8 | 826 | 3.421875 | 3 | [] | no_license | use std::io::{self, prelude::*};
fn fizzbuzz(x: i32, y:i32,n:i32){
for i in 1..n+1{
if i % x==0{
print!("Fizz");
}
if i % y==0{
print!("Buzz");
}
if i% x!=0 && i % y !=0{
print!("{}",i);
}
println!("");
... | true |
c389e26e477eec06295815a810ba22b7fd6c1b83 | Rust | ysouyno/x96check | /src/main.rs | UTF-8 | 3,501 | 2.671875 | 3 | [
"MIT"
] | permissive | use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::slice;
use structopt::StructOpt;
const IMAGE_DOS_SIGNATURE: i16 = 0x5A4D; // MZ
const IMAGE_NT_SIGNATURE: i32 = 0x00004550; // PE00
const IMAGE_FILE_MACHINE_I386: u16 = 0x014C; // Intel 386.
const IMAGE_FILE_MACHINE_AMD64: u16 = ... | true |
acb81f3392802fe84bf187e4284993dfe8e31cbe | Rust | threefoldtech/zos | /bootstrap/bootstrap/src/config.rs | UTF-8 | 3,017 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | use super::kparams;
use anyhow::Result;
use clap::{App, Arg};
#[derive(Debug)]
pub enum RunMode {
Prod,
Test,
Dev,
QA,
}
#[derive(Debug)]
pub enum Version {
V2,
V3,
}
fn runmode() -> Result<RunMode> {
let params = kparams::params()?;
let mode = match params.get("runmode") {
So... | true |
3096fb40ed8fb16dddada77ebc5c7e804fb9fd94 | Rust | igaozp/LearnRust | /base_content/src/patterns.rs | UTF-8 | 2,149 | 4.0625 | 4 | [] | no_license | // 简单的模式匹配
let x = 1;
match x {
y => println!("x: {} y: {}", x, y), // y = 1
}
// 多重模式
match x {
1 | 2 => println!("one or two"),
3 => println!("three"),
_ => println!("anything"),
}
// 通过模式匹配解构结构体
struct Point {
x: i32,
y: i32,
}
let origin = Point { x: 0, y: 0 };
match origin {
Point { ... | true |
46510e22843592d91c5e280b707a8d14acd004f9 | Rust | keitaroemotion/gitx | /src/lib.rs | UTF-8 | 2,258 | 3.296875 | 3 | [] | no_license | use std::fs::File;
use std::fs::OpenOptions;
use std::io::Write;
use std::io::{self, BufRead};
use std::path::Path;
use std::process;
const CONFIG_FILE:&'static str = ".git/alias";
pub struct Alias {
key: String,
value: String
}
impl Alias {
fn new(line: &str) -> Alias {
let mut lsp: Vec<&str> ... | true |
101580375b759c3c8496f0595f3c66d9d6070c7b | Rust | Rufflewind/synchrotron | /src/drop_off.rs | UTF-8 | 1,804 | 3.59375 | 4 | [
"MIT",
"Apache-2.0"
] | permissive | //! A single-threaded one-shot channel.
//!
//! # Example
//!
//! ```
//! use synchrotron::drop_off;
//!
//! let (sender, receiver) = drop_off::new();
//! let receiver = receiver.take().unwrap_err().unwrap();
//! sender.send(42).unwrap();
//! assert_eq!(42, receiver.take().unwrap());
//! ```
use std::cell::RefCell;
us... | true |
10a60f4ee01e2bebcf81a448c96c8c319aba5e78 | Rust | cyber-meow/ReactiveRs | /src/process/if_else.rs | UTF-8 | 4,105 | 3.15625 | 3 | [
"MIT"
] | permissive | use runtime::{SingleThreadRuntime, ParallelRuntime};
use continuation::{ContinuationSt, ContinuationPl};
use process::{Process, ProcessMut, ProcessSt, ProcessMutSt};
use process::{ProcessPl, ProcessMutPl, ConstraintOnValue};
/// Selects the process to run according to what the previous process returns.
pub struct IfEl... | true |
a60f0400812f9486ddc060c0e15248431216827e | Rust | manokara/bencode-rs | /benches/json.rs | UTF-8 | 1,494 | 2.640625 | 3 | [] | no_license | use bencode::Value;
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use nanoserde::{DeJson, SerJson};
const DICT_MIXED: &'static str = "{\
\"bar\":1,\
\"baz\":2,\
\"buz\":{\
\"abcde\":\"fghij\",\
\"boz\":\"bez\",\
\"fghij\":[\"klmnop\",\"qrstuv\",{\"wxyz\":0}... | true |
f5d43701940bf342cfdafc5c1102f6b3f393b713 | Rust | TheBestTvarynka/os-labs | /page-allocator/src/main.rs | UTF-8 | 621 | 2.546875 | 3 | [] | no_license | use page_allocator::allocator::Allocator;
fn main() {
let mut allocator = Allocator::new();
allocator.init();
allocator.dump();
println!("{}", allocator.alloc(6));
allocator.dump();
println!("{}", allocator.alloc(5));
allocator.dump();
println!("{}", allocator.alloc(5));
allocator.... | true |
8cd18441054ec7c0cff14286ee2e8d603c3c4e34 | Rust | kcchu/snow | /src/lib.rs | UTF-8 | 2,292 | 2.828125 | 3 | [
"Unlicense"
] | permissive | //! The `snow` crate is a straightforward, Hard To Fuck Up™ Noise Protocol implementation.
//!
//! Read the [Noise Protocol Framework Spec](http://noiseprotocol.org/noise.html) for more
//! information.
//!
//! The typical usage flow is to use [`Builder`] to construct a [`Session`], which is main
//! state machine you ... | true |
717d564dc1ce5c65aaf4e249d8fc079ea20c1536 | Rust | icechair/chsslib | /src/lib.rs | UTF-8 | 10,178 | 3.09375 | 3 | [
"Unlicense"
] | permissive | pub mod bitboard;
pub mod piece;
pub use bitboard::Bitboard;
pub use bitboard::Square;
pub use piece::Piece;
use std::fmt;
pub struct Castling(u8);
impl Castling {
pub fn new(v: u8) -> Self {
return Self(v);
}
pub fn can_white_king(&self) -> bool {
self.0 & 1 == 1
}
p... | true |
c8b54eb8a2f2783f7f1797db7a146e08e1e5770f | Rust | killercup/static-filez | /tests/roundtrip.rs | UTF-8 | 2,197 | 2.828125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate tempfile;
use std::collections::HashMap;
use std::fs::{create_dir, File};
use std::io::Write;
use std::process::{Child as ChildProcess, Stdio};
use tempfile::tempdir;
#[test]
fn roundtrip() -> Result<(), Box<dyn std::error::Error>> {
let dir = tempdir()?;
let files: HashMap<String, String> = (0.... | true |
b4852e2013fefb6dc81b6276b2206208cac06484 | Rust | blindley/stdex | /src/kitchen_sink.rs | UTF-8 | 752 | 3.03125 | 3 | [] | no_license |
pub trait Increment {
fn increment(&mut self);
fn next(mut self) -> Self where Self: Copy {
self.increment();
self
}
}
pub trait Decrement {
fn decrement(&mut self);
fn previous(mut self) -> Self where Self: Copy {
self.decrement();
self
}
}
macro_rules! impl_i... | true |
f77a98675096a50d12a4145b7135daf8819f2406 | Rust | SDP-G2/backend | /sdp-backend/src/api/auth.rs | UTF-8 | 642 | 2.546875 | 3 | [] | no_license | use crate::auth::Token;
use crate::user::User;
use actix_web::{post, web, web::Data, HttpResponse};
use serde::{Deserialize, Serialize};
use sqlx::postgres::PgPool;
#[derive(Serialize, Deserialize, Debug)]
pub struct AuthRequest {
pub user_name: String,
pub password: String,
}
#[post("/auth")]
pub async fn a... | true |
db9b62122ee43d02a2e1ba54428f1b568e769d63 | Rust | aws/random-cut-forest-by-aws | /Rust/src/util.rs | UTF-8 | 648 | 2.859375 | 3 | [
"Apache-2.0"
] | permissive | use crate::{errors::RCFError, types::Result};
pub(crate) fn add_to(a: &f64, b: &mut f64) {
*b += *a;
}
pub(crate) fn divide(a: &mut f64, b: usize) {
*a /= b as f64;
}
pub(crate) fn add_nbr(a: &(f64, usize, f64), b: &mut Vec<(f64, usize, f64)>) {
b.push(*a)
}
pub(crate) fn nbr_finish(_a: &mut Vec<(f64, us... | true |
9bfd334997322907be76da16a9f49b30c5cd63f6 | Rust | mattsse/crossref-rs | /src/query/journals.rs | UTF-8 | 905 | 2.65625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::error::Result;
use crate::query::works::{WorksCombiner, WorksFilter, WorksIdentQuery, WorksQuery};
use crate::query::{Component, CrossrefQuery, CrossrefRoute, ResourceComponent};
/// constructs the request payload for the `/journals` route
#[derive(Debug, Clone)]
pub enum Journals {
/// target a specifi... | true |
4e49241fdc884028e5162c0baaefe42345be5b31 | Rust | mesalock-linux/crates-io | /vendor/time/src/format/offset.rs | UTF-8 | 1,169 | 2.90625 | 3 | [
"Apache-2.0",
"Unlicense",
"BSD-3-Clause",
"0BSD",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Formatting helpers for a `UtcOffset`.
#![allow(non_snake_case)]
use crate::{
error,
format::{
parse::{try_consume_exact_digits, try_consume_first_match},
Padding, ParsedItems,
},
ParseResult, UtcOffset,
};
use core::fmt::{self, Formatter};
/// UTC offset
pub(crate) fn fmt_z(f: &mu... | true |
868290b3710f533c4f8812c0d95d6758e917bcdd | Rust | fredhsu/eostool | /src/main.rs | UTF-8 | 3,398 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | // #![deny(warnings)]
// use std::collections::HashMap;
use std::env;
extern crate reqwest;
// use reqwest::Error;
extern crate serde;
use serde::{Deserialize, Serialize};
extern crate serde_json;
// use serde_json::json;
#[macro_use]
extern crate clap;
use clap::App;
#[derive(Debug, Serialize, Deserialize)]
struct J... | true |
dee100ba0a64916f942bb277929282d1637931c6 | Rust | book-resources/rustlernen | /13-Collections/programmtext-208.rs | UTF-8 | 200 | 2.90625 | 3 | [] | no_license | use std::collections::HashSet;
fn main() {
let elements = vec!["Auto", "Reifen", "Auto"];
let set: HashSet<_> = elements.iter().collect();
for elem in &set {
println!("{}", elem);
}
} | true |
09594fa6f39dee866e2bae8a74beefeabca8cbaf | Rust | wangyanhai/calyx | /interp/src/interpreter.rs | UTF-8 | 11,150 | 2.515625 | 3 | [
"MIT"
] | permissive | use super::{environment::Environment, primitives};
use calyx::{errors::FutilResult, ir};
use std::collections::HashMap;
/// Evaluates a group, given an environment.
pub fn eval_group(
group: ir::RRC<ir::Group>,
env: &Environment,
) -> FutilResult<Environment> {
eval_assigns(&(group.borrow()).assignments, &... | true |
aecd47d516f500c6ed614274e82f440166dccdfa | Rust | axm2/adventofcode | /1/main.rs | UTF-8 | 909 | 3.5625 | 4 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
fn main() {
let filename = "src/input.txt";
// Open the file in read-only mode (ignoring errors).
let file = File::open(filename).unwrap();
let reader = BufReader::new(file);
let mut result = 0;
// Read the file line by line using the lines... | true |
eb85777ba7523a12a63fdd3b385d8fdb1131fde4 | Rust | akoptelov/fuzzing-ci | /src/config.rs | UTF-8 | 3,731 | 2.578125 | 3 | [] | no_license | use std::{
collections::HashMap,
ffi::OsStr,
fs::File,
io::Read,
path::PathBuf,
};
use derive_new::new;
use failure::{Error, ResultExt};
use serde::Deserialize;
use url::Url;
#[derive(Clone, Deserialize, new)]
pub struct Config {
pub address: String,
pub url: Option<Url>,
pub branches:... | true |
63be897bccad0e1ecc69bcf2ee262952f1fd24c5 | Rust | jerdmann/thesoulforge | /advent_of_code/2020/aoc01/src/main.rs | UTF-8 | 3,608 | 3.5625 | 4 | [] | no_license | use std::io::{stdin, Read};
type NumT = usize;
type NumVec = Vec<NumT>;
/// Simple tracking struct for an n-ary vector of integers.
#[derive(Debug)]
struct Cursor {
v: NumVec,
lim: usize,
}
impl Cursor {
pub fn new(lim: usize, slots: usize) -> Self {
let mut c = Cursor {
v: vec![],
... | true |
16dac4aea3b0bfc6971dcc0f73815b71961edb3d | Rust | fmdkdd/asobiba | /rust/test/lifetimes-str.rs | UTF-8 | 971 | 3.90625 | 4 | [] | no_license | fn main() {
// 'a' does not live long enough, as expected because it will be dropped at
// the end of its block, but 'c' still refers to its value.
{
let mut c = None;
{
let a = Vec::new();
c = Some(id(&a));
}
println!("{:?}", c);
}
// But here, even though 'c' can refer to the va... | true |
62a44b6a72d0c4666191f486b678b5d4c5e0337c | Rust | garyttierney/rust-rdf | /src/tripledb/table.rs | UTF-8 | 3,220 | 2.9375 | 3 | [] | no_license | extern crate rocksdb;
extern crate byteorder;
use self::byteorder::ByteOrder;
use self::rocksdb::{DB, WriteBatch, Options, ColumnFamily, ColumnFamilyDescriptor};
use std::cmp::Ordering;
use std::marker::PhantomData;
use std::sync::Arc;
use std::sync::RwLock;
use std::vec::Vec;
pub trait TableValue: Ord {
/// Enc... | true |
7c57eff0d9e9e6ecea75a2b32025aa5ff0ccf847 | Rust | peterjoel/pest_calc | /src/calc.rs | UTF-8 | 3,488 | 3.359375 | 3 | [] | no_license | use std::collections::HashMap;
use pest::{
Parser,
error::Error as PestError,
iterators::{Pair, Pairs},
prec_climber::{Operator, PrecClimber, Assoc},
};
#[derive(Parser)]
#[grammar = "ident.pest"]
struct CalcParser;
pub type Error = PestError<Rule>;
pub struct Calc<'a> {
climber: PrecClimber<Rule... | true |
77e799abfa08429c37b571d138fe99f3c45421fa | Rust | juhofriman/bogus-lang | /src/ast/e_minus.rs | UTF-8 | 2,697 | 3.515625 | 4 | [] | no_license | use crate::ast::{Expression, Value, EvaluationError};
use crate::ast::scope::Scope;
use std::rc::Rc;
pub struct PrefixMinusExpression {
expression: Rc<dyn Expression>
}
impl PrefixMinusExpression {
pub fn new(expression: Rc<dyn Expression>) -> PrefixMinusExpression {
PrefixMinusExpression {
... | true |
77b800cff9a9efbdd4e0897b9bc65bee45a7da76 | Rust | luteberget/junction | /lib/railmlio/src/xml.rs | UTF-8 | 8,023 | 2.734375 | 3 | [] | no_license | use crate::model::*;
use roxmltree as xml;
type BoxResult<T> = Result<T, Box<dyn std::error::Error>>;
pub fn parse_railml(data :&str) -> BoxResult<RailML> {
let doc = roxmltree::Document::parse(data)?;
parse_railml_xml(&doc.root_element())
}
fn parse_railml_xml(root :&xml::Node) -> BoxResult<RailML> {
Ok... | true |
2dec7914ac5c99088cea6ac5784abf018038c637 | Rust | omegablitz/distributary | /examples/backend.rs | UTF-8 | 1,288 | 2.859375 | 3 | [] | no_license | use std::collections::HashMap;
use distributary::{Blender, DataType, Mutator, Recipe};
type Datas = Vec<Vec<DataType>>;
type Getter = Box<Fn(&DataType) -> Result<Datas, ()> + Send + Sync>;
pub struct Backend {
getters: HashMap<String, Getter>,
mutators: HashMap<String, Mutator>,
recipe: Recipe,
soup: ... | true |
1f3191d0e38471ef8d68087def349ae3fdced90b | Rust | amoghyermalkar123/slings | /examples/tcp_server.rs | UTF-8 | 1,134 | 2.609375 | 3 | [
"MIT"
] | permissive | use std::io;
use std::net::SocketAddr;
use std::time::Duration;
use slings::net::TcpListener;
use slings::time::delay_for;
use slings::AsyncWriteExt;
fn main() -> io::Result<()> {
slings::block_on(async {
let addr: SocketAddr = "127.0.0.1:8080".parse().unwrap();
let listener = TcpListener::bind(ad... | true |
82d3b7d1328603bfbaee88ab4dd1767abb936c05 | Rust | melotic/docx-rs | /src/document/body.rs | UTF-8 | 1,852 | 3.03125 | 3 | [
"MIT"
] | permissive | use derive_more::From;
use strong_xml::{XmlRead, XmlWrite};
use crate::__xml_test_suites;
use crate::document::{Paragraph, Table};
/// Document Body
///
/// This is the main document editing surface.
#[derive(Debug, Default, XmlRead, XmlWrite)]
#[cfg_attr(test, derive(PartialEq))]
#[xml(tag = "w:body")]
pub struct Bo... | true |
48675eba4f60ee47270fb0ca9f5737aed2ae5670 | Rust | tupshin/thunderdome | /src/graph.rs | UTF-8 | 837 | 3.171875 | 3 | [
"BSD-2-Clause"
] | permissive | use std::collections::HashMap;
use std::mem;
use vertex::{Vertex,VertexProxy};
#[derive(Debug)]
pub struct Graph {
elements: i64,
// we transmute our Boxed vertex into a pointer later
vertices: HashMap<i64, *mut Vertex>,
}
impl Graph {
pub fn new() -> Box<Graph> {
let vertices: HashMap<i64, *... | true |
dc6053280ca000ebc788ee77b3b4e9c5125fa33e | Rust | mahi97/rusting | /variables/src/main.rs | UTF-8 | 720 | 3.59375 | 4 | [] | no_license | fn main() {
// VARIABLES
let mut x = 5;
println!("Hello, world!{}", x);
x = 6;
let x = x + 2;
println!("NEW X: {}", x);
let guess: u32 = "42".parse().expect("Not a number!");
// CONST
const MAX_INT: u32 = 1000_000;
// DATA TYPES
let x = 2.0;
let mahi: i32 = 1000_000_00... | true |
8bbcf2ff062bf81dde21c76b16400046f587843f | Rust | nats-io/nats.rs | /async-nats/src/jetstream/message.rs | UTF-8 | 20,408 | 2.5625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2020-2022 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to ... | true |
ed5c26da3a44cd117541465148f556c41b9c9d4f | Rust | sebpuetz/project-euler | /src/bin/ex11.rs | UTF-8 | 1,893 | 3.140625 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufReader, BufRead};
pub fn main() {
let f = File::open("ex11_input").expect("Input file missing");
let mut grid = Vec::new();
for line in BufReader::new(f).lines() {
let line = line.expect("Can't read line");
let row = line.split_whitespace()
.m... | true |
eb6f670f4955b5e6b7fb16daa22be8db376a20bd | Rust | Bruno-Mascarenhas/competitive-programming | /uri/1002.rs | UTF-8 | 246 | 2.90625 | 3 | [] | no_license | fn get_input() -> f64 {
let mut buffer = String::new();
std::io::stdin().read_line(&mut buffer).expect("Failed");
buffer.trim().parse::<f64>().unwrap()
}
fn main() {
let r = get_input();
println!("A={:.4}", 3.14159f64*r*r);
} | true |
6f977ec525bdac751694f955944215e6f9d8940f | Rust | doytsujin/yew | /packages/yew-router/tests/router_unit_tests.rs | UTF-8 | 1,132 | 2.609375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use wasm_bindgen_test::{wasm_bindgen_test as test, wasm_bindgen_test_configure};
use yew_router::prelude::*;
wasm_bindgen_test_configure!(run_in_browser);
#[test]
fn router_always_404() {
#[derive(Routable, Debug, Clone, PartialEq)]
enum AppRoute {
#[at("/")]
Home,
#[at("/:id")]
... | true |
d9b19264418b618f814fd71604c8a209f3abcd89 | Rust | google-apis-rs/generated | /gen/cloudidentity/v1/cli/src/main.rs | UTF-8 | 13,745 | 2.5625 | 3 | [] | no_license | use clap::{App, AppSettings, Arg, SubCommand};
use default_boxed::DefaultBoxed;
#[derive(DefaultBoxed)]
struct Outer<'a, 'b> {
inner: HeapApp<'a, 'b>,
}
struct HeapApp<'a, 'b> {
app: App<'a, 'b>,
}
impl<'a, 'b> Default for HeapApp<'a, 'b> {
fn default() -> Self {
let mut app = App::new("cloudiden... | true |
fd572a18944752579053efadab8afb03a09a1fdc | Rust | jellevos/scicrypt | /scicrypt-traits/src/threshold_cryptosystems.rs | UTF-8 | 4,900 | 3.546875 | 4 | [
"MIT"
] | permissive | use crate::cryptosystems::{AssociatedCiphertext, EncryptionKey};
use crate::randomness::GeneralRng;
use crate::randomness::SecureRng;
use crate::security::BitsOfSecurity;
use crate::DecryptionError;
/// An asymmetric threshold cryptosystem is a system of methods to encrypt plaintexts into
/// ciphertexts, but instead ... | true |
17c25b987c89c35314154e40c49ab4cd3f157044 | Rust | apparentorder/aoc | /2021/src/day13.rs | UTF-8 | 2,115 | 2.96875 | 3 | [] | no_license | use crate::aoc;
use std::collections::HashSet;
type Grid = HashSet<Coord>;
type Coord = (i32, i32);
type Folds = Vec<Coord>;
fn fold(old_grid: Grid, folds: Folds) -> Grid {
let mut grid = old_grid.clone();
for (fold_x, fold_y) in folds {
let mut new_grid = grid.clone();
for &(dot_x, dot_y) in &grid {
if fo... | true |
84d164b7b866960cc8ac35c820fe66d003f6dd70 | Rust | charliethomson/linkedlrst | /src/old5.rs | UTF-8 | 3,072 | 3.421875 | 3 | [] | no_license | #![feature(ptr_internals)]
use std::{
mem::{size_of},
alloc::{Layout, alloc_zeroed, dealloc},
ptr::{Unique, null, null_mut, replace, read, write},
fmt::{Display, Debug, Formatter, Result as fmt_Result},
};
struct Node<T> {
value: Option<T>,
next: *mut Self,
}
impl<T> Node<T> {
fn new() -> S... | true |
0a48ec244a32c78fb5747e6649689d68d866e2a3 | Rust | kevbot18/game_of_life | /src/main.rs | UTF-8 | 8,827 | 2.515625 | 3 | [] | no_license | /* TODO:
- Zoom to Center
- currently zooms to top left block
- Implement a UI
- display basic help info
- add an FPS counter (current one is very bad)
- Separate Cell Buffer from UI Buffer
- use separate textures for cells grid and UI
*/
extern crate rand;
extern crate sdl2;
extern crate time;
use rand::Rng;
u... | true |
0650b9adae099e51351bb447308bf3ac05c501af | Rust | mitsuhiko/logteewoop | /src/actors/websocket.rs | UTF-8 | 3,427 | 2.546875 | 3 | [
"Apache-2.0"
] | permissive | use std::sync::Arc;
use std::time::{Duration, Instant};
use actix::{Actor, ActorContext, Addr, AsyncContext, Handler, Message, StreamHandler};
use actix_web::ws;
use serde::{Deserialize, Serialize};
use serde_json;
use uuid::Uuid;
use crate::actors::streamcache::{LogLine, StreamCache, SubscribeSocket, UnsubscribeSock... | true |
56a21007eefd2a0612cc64e2c506360ca108f7e8 | Rust | NDNLink/NDNProtocol | /libp2p/protocols/mplex/src/pause.rs | UTF-8 | 3,517 | 3.09375 | 3 | [
"MIT"
] | permissive | // Copyright 2020 Netwarps Ltd.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, dis... | true |
96fb53e7b04b19bbec807a201fd3c86062af1df0 | Rust | brentward/bwos | /pi/src/font/mod.rs | UTF-8 | 4,415 | 2.578125 | 3 | [] | no_license | pub mod charset;
mod freebsd_cp850;
mod freebsd_teletext;
pub const CR: u8 = b'\r';
pub const LF: u8 = b'\n';
pub const BELL: u8 = 7;
pub const BACK: u8 = 8;
pub const DEL: u8 = 127;
#[derive(Copy, Clone, Debug)]
pub struct CP850Font {
char_count: usize,
pub char_size: usize,
pub char_height: usize,
p... | true |
a9b1cb138dc60e55ab9f8f1c1a4c1dc349840aca | Rust | Wind-River/rust | /src/test/mir-opt/uninhabited_enum_branching.rs | UTF-8 | 4,289 | 3.09375 | 3 | [
"MIT",
"BSD-3-Clause",
"Apache-2.0",
"BSD-2-Clause",
"LicenseRef-scancode-other-permissive",
"NCSA"
] | permissive | enum Empty { }
// test matching an enum with uninhabited variants
enum Test1 {
A(Empty),
B(Empty),
C
}
// test an enum where the discriminants don't match the variant indexes
// (the optimization should do nothing here)
enum Test2 {
D = 4,
E = 5,
}
fn main() {
match Test1::C {
Test1::... | true |
32d07e9720903bc421dcc39e4b6e1c6c20024df3 | Rust | second-state/wasm-learning | /nodejs/deps/rusty_machine/src/learning/toolkit/activ_fn.rs | UTF-8 | 2,721 | 3.828125 | 4 | [
"MIT"
] | permissive | //! Activation Functions.
//!
//! This module contains a number of structs implementing the `ActivationFunc` trait.
//!
//! These structs are used within Neural Networks and
//! Generalized Linear Regression (not yet implemented).
//!
//! You can also create your own custom activation Functions for use in your models.
... | true |
708d7d5a2c3b2482b7e9ccfc4a2fa8ccb0f318e9 | Rust | ammarc/spherical-cow | /src/util/mod.rs | UTF-8 | 2,396 | 3.40625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! Useful helper functions such as a fast ray casting method and volume finder for use with arbitrary shaped triangular meshes.
use nalgebra::{self, Point3, Vector3};
use nalgebra::core::Matrix;
/// Find the baycentric coordinates `(u,v)` and distance `t` given three triangle veriticies `vert0`, `vert1`, `vert2` and... | true |
0bcf47f4e8a31f9e291b4fd464b9b33969f21a6e | Rust | JM4ier/pluto.dev | /src/main.rs | UTF-8 | 4,315 | 2.53125 | 3 | [] | no_license | use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
mod code;
mod config;
mod editing;
mod models;
mod org;
mod polyring;
mod render;
mod rss;
mod schema;
use models::Post;
use org::*;
#[macro_use]
extern crate diesel;
use diesel::{pg::PgConnection, prelude::*};
use dotenv::dotenv;
use std::env;
typ... | true |
6ad927c9a2cd52410ff304a74062ebf954ff0939 | Rust | qingshi163/leetcode_rust | /src/goat_latin.rs | UTF-8 | 1,247 | 3.328125 | 3 | [
"MIT"
] | permissive | #[allow(dead_code)]
fn to_goat_latin(s: String) -> String {
let ret = s
.into_bytes()
.split(|&x| x == b' ')
.zip(1usize..)
.map(|(x, i)| {
let mut v = match x[0] {
b'a' | b'e' | b'i' | b'o' | b'u' | b'A' | b'E' | b'I' | b'O' | b'U' => x.to_vec(),
... | true |
08f9ff97d643d88b63b50833cbf0886babcb695b | Rust | Geal/typedopts | /examples/getopt.rs | UTF-8 | 2,407 | 3.046875 | 3 | [
"MIT"
] | permissive | extern crate getopts;
extern crate typedopts;
extern crate rustc_serialize;
use std::env;
use getopts::Options;
use typedopts::{DecodeResult,ErrorType};
#[allow(non_camel_case_types)]
#[derive(RustcDecodable)]
enum Color {
red,
blue
}
#[derive(RustcDecodable)]
struct TestStruct1 {
data_int: u8,
data_str: St... | true |
889baa281440669fe98e8931587f2e53d97219b3 | Rust | YanceyOfficial/leetcode-trip | /src/leetcode/rust/src/medium/question_57.rs | UTF-8 | 748 | 2.9375 | 3 | [
"MIT"
] | permissive | use std::cmp;
#[allow(unused)]
pub fn insert(intervals: Vec<Vec<i32>>, new_interval: Vec<i32>) -> Vec<Vec<i32>> {
let n = intervals.len();
let mut new_interval = new_interval;
let mut new_intervals = vec![];
let mut i = 0;
while i < n && intervals[i][1] < new_interval[0] {
new_intervals.pu... | true |
7f2968ca9e38bb4189a08be628077010e2177769 | Rust | LanaCoyote/rust-irc | /src/utils/debug.rs | UTF-8 | 1,174 | 3.15625 | 3 | [] | no_license | use std::fmt;
pub enum Level {
Err,
Warn,
Oper,
Info,
DispIn,
DispOut,
}
#[allow(dead_code)]
pub fn err <T,S> ( s : T, e : S ) where T : fmt::Display, S : fmt::Display {
let data = format! ( "err in {} : {}", s, e );
log( Level::Err, data );
}
#[allow(dead_code)]
pub fn warn <T,S> ( s : T, w : S ) wh... | true |
424be1c2f052b8a8c8a4d095866352cf7f05d1b9 | Rust | aji/miau | /src/commands.rs | UTF-8 | 4,364 | 3.140625 | 3 | [] | no_license | use irc::Message;
use network::Network;
use network::Output;
/// Handles a command in the given command handling context.
pub fn handle_command<X: Context>(ctx: &mut X, cmd: &str, _args: &str) {
match cmd {
"version" => {
ctx.reply(format!("i am {} v{}",
env!("CARGO_PKG_NAME"),... | true |
1dbe7384307dc0eee5d57f91e6eb563bd5fd33a1 | Rust | gedkott/space_invaders | /src/game_characters/shooter.rs | UTF-8 | 1,034 | 3.328125 | 3 | [] | no_license | use crate::Direction;
pub const SHOOTER_STEP_DISTANCE: i32 = 10;
const SHOOTER_HEALTH: i32 = 50;
pub struct Shooter {
pub x_pos: i32,
pub y_pos: i32,
pub width: u32,
pub height: u32,
pub direction: crate::Direction,
pub health: i32,
}
impl Shooter {
pub fn new(canvas_width: i32, canvas_he... | true |
b4af373ac297260ad3aec42d13e8a7e7eeb4420c | Rust | Rust-Wroclaw/rust-wroclaw | /talk-archive/2022-07-can-you-trigger-all-clippy-lints-and-live-to-tell-the-tale/src/more_than_trivial/unit_cmp.rs | UTF-8 | 182 | 2.9375 | 3 | [] | no_license | pub fn compare_items<T, F>(a: T, b: T, f: F) -> bool
where
F: Fn(T) -> i32,
{
let a_val = {
f(a);
};
let b_val = {
f(b);
};
a_val == b_val
}
| true |
55c13e25ee53e1a471900e661aeb1fda1141b116 | Rust | mwelsch/wasm-encryption-performance-test | /src/crypto_aes.rs | UTF-8 | 3,701 | 2.921875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use wasm_bindgen::prelude::*;
extern crate crypto;
//rust crypto aes
use crypto::{ symmetriccipher, buffer, aes, blockmodes };
use crypto::buffer::{ ReadBuffer, WriteBuffer, BufferResult };
#[wasm_bindgen]
pub fn rust_crypto_aes_encrypt_decrypt(message: &str, key: &str, iv: &str){
let encrypted = RustCryptoAes:... | true |
fd1dd2afa463cd8dad61886d00f642c7e8990309 | Rust | vamolessa/ase-rs | /src/lib.rs | UTF-8 | 2,122 | 2.6875 | 3 | [
"MIT"
] | permissive | #![allow(non_upper_case_globals)]
use std::io::{self, Cursor, Read, Seek, Write};
pub mod header;
pub use self::header::*;
pub mod frame;
pub use self::frame::*;
pub mod chunk;
pub use self::chunk::*;
pub mod color;
pub mod helpers;
pub use self::color::*;
/*
https://github.com/aseprite/aseprite/blob/master/docs/a... | true |
5390e0cbc22af45edb9264390b40712d2c311b41 | Rust | Drumato/asmpeach | /src/assembler/resource/operand/imm.rs | UTF-8 | 1,593 | 3.28125 | 3 | [
"MIT"
] | permissive | use fmt::Formatter;
use std::fmt;
#[derive(Eq, Ord, PartialOrd, PartialEq, Debug, Clone, Copy)]
pub enum Immediate {
I8(i8),
I16(i16),
I32(i32),
}
impl Immediate {
pub fn to_bytes(&self) -> Vec<u8> {
match self {
Immediate::I8(v8) => vec![*v8 as u8],
Immediate::I16(v16)... | true |
03cb8162c2708661e950af254b4fc9e200704917 | Rust | thepowersgang/rust_os | /Kernel/Core/arch/armv7/sync.rs | UTF-8 | 1,341 | 2.59375 | 3 | [
"BSD-2-Clause"
] | permissive | /*
*/
use core::sync::atomic::{AtomicBool,Ordering};
pub struct SpinlockInner
{
flag: AtomicBool,
}
impl SpinlockInner
{
pub const fn new() -> SpinlockInner {
SpinlockInner { flag: AtomicBool::new(false) }
}
pub fn inner_lock(&self)
{
while self.flag.swap(true, Ordering::Acquire) {
// TODO: Once SMP is a... | true |
62c4f4e898226be3914c71779256740fddb0ed34 | Rust | codeOverFlow/parg | /examples/basic_usage.rs | UTF-8 | 1,133 | 3.046875 | 3 | [
"LicenseRef-scancode-warranty-disclaimer"
] | no_license | extern crate parg;
use parg::create_cli_arguments;
use parg::Arg;
use parg::CliArguments;
use parg::Type;
fn main() {
// create the required argument --threshold <u8 value>
let threshold = Arg::with_value("threshold", Type::ReadAsU8, true);
threshold.set_description("a little description for the argument"... | true |
82587e0a42f8c764f246fd1f6d00823839d643e3 | Rust | ischeinkman/fakefat | /src/stdimpl.rs | UTF-8 | 3,502 | 2.921875 | 3 | [
"MIT"
] | permissive | use crate::datetime::{Date, Time};
use crate::traits::{DirEntryOps, DirectoryOps, FileMetadata, FileOps, FileSystemOps};
use std::fs::{self, DirEntry, File, Metadata};
use std::io::{self, Read, Seek};
use std::path::PathBuf;
use std::time::SystemTime;
impl FileOps for File {
fn read_at(&mut self, offset: usize, bu... | true |
0d607515b7fed93988f85a396d4b0bb7e572db77 | Rust | jiyilanzhou/chw | /online_rust/base/3_str.rs | UTF-8 | 3,300 | 4.28125 | 4 | [] | no_license |
/*
0. str
&str 并非整体("&"代表取地址而 str 是 Rust 中不可变的静态字符串)
故 &str 是获取 str 的地址(即指向 str 的引用[" & "为取地址符])
1. 语句与表达式
表达式有返回值如" if a==b {} "则" a==b "则为表达式(返回 bool)
*/
fn main_0() {
// 将数据写入 str 并对其创建引用 & 赋给 variable (禁止操作 str)
let variable = "chw";
// 完整写法
let variable: &'static str = "chw";
pr... | true |
62aff69139326bbf11350182787d1051d7a5e44e | Rust | infinityb/rust-rtree | /src/test_helpers/mod.rs | UTF-8 | 692 | 2.984375 | 3 | [] | no_license | use std::cmp::{min, max};
use super::{BBox, Object, Mbr, Intersection};
use ::vec3::Vec3;
use ::ray::Ray;
const SPHERE_RADIUS_TOO_SMALL: &'static str = "sphere radius must be above zero";
pub struct Sphere {
origin: Vec3,
radius: f64,
}
impl Sphere {
pub fn new(origin: Vec3, radius: f64) -> Result<Spher... | true |
99dae7a2e794626de698ecb1d6983f68a5dbf843 | Rust | devg1120/rust_test | /test02/src/main.rs | UTF-8 | 1,064 | 3.5625 | 4 | [] | no_license | //ジェネリクス
#[derive(Debug)]
struct Point<T> {
x: T,
y: T,
}
impl<T> Point<T> {
fn x(&self) -> &T { &self.x }
}
#[derive(Debug)]
struct Point2<T,U> {
x: T,
y: U,
}
impl<T, U> Point2<T, U> {
fn mixup<V, W>(self, other: Point2<V, W>) -> Point2<T, W> {
Point2 { x: self.x, y: other.y }
... | true |
870008498386b343670e90a85e0bacc39540928b | Rust | dominickm/stl-thumb | /src/mesh.rs | UTF-8 | 6,114 | 3.109375 | 3 | [
"MIT"
] | permissive | extern crate cgmath;
extern crate stl_io;
use std::error::Error;
use std::fs::File;
use std::fmt;
#[derive(Copy, Clone)]
pub struct Vertex {
position: stl_io::Vertex,
//texcoords: [f32; 2],
}
implement_vertex!(Vertex, position);
//implement_vertex!(Vertex, position, texcoords);
#[derive(Copy, Clone)]
pub st... | true |
365259263c33564c8d49c8cec2285c8e709d0492 | Rust | mnts26/aws-sdk-rust | /sdk/aws-config/src/profile/credentials/repr.rs | UTF-8 | 14,870 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | /*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
* SPDX-License-Identifier: Apache-2.0.
*/
//! Flattened Representation of an AssumeRole chain
//!
//! Assume Role credentials in profile files can chain together credentials from multiple
//! different providers with subsequent credentials bein... | true |
c9c2313cb9c67d5f160d5d748c36f98740211792 | Rust | thaodt/enigma_dapp | /src/lib.rs | UTF-8 | 4,518 | 2.671875 | 3 | [] | no_license | #![no_std]
extern crate eng_wasm;
extern crate eng_wasm_derive;
extern crate rustc_hex as hex;
#[macro_use]
extern crate serde_derive;
extern crate serde;
extern crate chrono;
use eng_wasm::*;
use eng_wasm_derive::pub_interface;
use chrono::{DateTime, Duration, Utc};
use serde::{Serialize, Deserialize};
// use ether... | true |
a514d61163e7ea1e9c557c4f8f4c00900de6d23c | Rust | nathdobson/crossword | /src/generate.rs | UTF-8 | 14,749 | 2.59375 | 3 | [] | no_license | /*fn search(width: usize, height: usize, words: &[Word], tries: &[&Trie], acrosses: &mut Vec<Word>) {
if height == acrosses.len() {
let downs: Vec<Word> = (0..width).map(|x| (0..height).map(|y| acrosses[y][x]).collect()).collect();
if !iproduct!(acrosses.iter(), downs.iter()).any(|(a, b)| a == b) {
... | true |
ffa203d1678b53d1bf224c4283e31c027551773c | Rust | WebAssembly/wasi-libc | /tools/wasi-headers/src/main.rs | UTF-8 | 1,929 | 2.578125 | 3 | [
"Apache-2.0",
"MIT",
"LLVM-exception",
"NCSA",
"BSD-2-Clause"
] | permissive | #[macro_use]
extern crate clap;
use anyhow::Result;
use clap::{Arg, SubCommand};
use std::fs;
use std::path::Path;
use wasi_headers::{generate, libc_wasi_api_header, libc_wasi_api_source, snapshot_witx_files};
pub fn run(
inputs: &[impl AsRef<Path>],
header_output: impl AsRef<Path>,
source_output: impl As... | true |
cba7b0fb795ac0ed183a5edede6561405cf927fd | Rust | dbosomworth/advent-2020 | /src/day2.rs | UTF-8 | 4,040 | 3.75 | 4 | [] | no_license | mod utility;
#[derive(Copy, Clone)]
struct PasswordRule {
min: i64,
max: i64,
character: char
}
#[derive(Clone)]
struct PasswordEntry {
rule: PasswordRule,
password: String,
is_valid_part_one: bool,
is_valid_part_two: bool,
}
/*
is_part_one_password_valid calculates if password satisi... | true |
65e44afd4d95f2ef1123ac732d554b12bb06afa2 | Rust | HerringtonDarkholme/leetcode | /src/409_frog_jump.rs | UTF-8 | 2,174 | 3.40625 | 3 | [] | no_license | pub struct Solution;
use std::collections::{HashSet, VecDeque};
/*
use std::collections::{HashMap, HashSet};
impl Solution {
pub fn can_cross(stones: Vec<i32>) -> bool {
let mut reachables = HashMap::new();
let mut max = 0;
for &stone in &stones {
reachables.insert(stone, HashSe... | true |
151953835ba6496d734441fc324912466b627363 | Rust | 9tykeshav/Rust | /actix-example.rs | UTF-8 | 1,941 | 2.890625 | 3 | [] | no_license | extern crate actix_web;
extern crate sqlx ;
use actix_web::{get , post , web , App , HttpResponse , HttpServer , Responder , HttpRequest , Result };
use std::time::{Duration, Instant};
use std::thread::sleep;
use sqlx::postgres::PgPoolOptions;
use sqlx::Row;
#[get("/bruh")]
async fn bruh() -> impl Responder {
Htt... | true |
937733d0e4d1d42675b4995f2a8cb0db1842b6b6 | Rust | tetsuharuohzeki/cmdshelf | /src/reporter.rs | UTF-8 | 914 | 3.375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::io::Write;
enum Color {
Red,
Green,
Yellow,
Reset,
}
fn color_string(color: Color) -> String {
match color {
Color::Red => "\u{001B}[0;31m".to_string(),
Color::Green => "\u{001B}[0;32m".to_string(),
Color::Yellow => "\u{001B}[0;33m".to_string(),
Color::... | true |
9123a24bb1ead6f3ef0d2ceb4a194b9cd8264186 | Rust | gguimond/rust | /sandbox/src/main.rs | UTF-8 | 23,705 | 3.328125 | 3 | [] | no_license | //! # Rust practice
#![warn(missing_docs)]
#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "https://www.rust-lang.org/favicon.ico",
html_root_url = "https://doc.rust-lang.org/")]
extern crate phrases;
pub use phrases::english::greetings::hello as h... | true |
a5ce07fdd67e34252f79312f4aa22f3f7550d723 | Rust | KISSMonX/happyrust | /demo/src/main.rs | UTF-8 | 602 | 3.703125 | 4 | [
"Apache-2.0"
] | permissive | fn main() {
let w = 233;
let l = 10;
let rect = (30, 50);
let rect2 = Rectangle {
width: 100,
length: 100,
};
println!("{}", area(w, l));
println!("{}", area2(rect));
println!("{}", area3(&rect2));
println!("{}", area4(rect2));
}
struct Rectangle {
width: u32... | true |
32b08737592300da0ccbe530f4c4a6f1c07b0718 | Rust | fyang93/rust-leetcode | /src/p0065_valid_number.rs | UTF-8 | 234 | 3.125 | 3 | [] | no_license | // cheat
pub fn is_number(s: String) -> bool {
s.trim().parse::<f32>().is_ok()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(is_number(String::from(" -90e3 ")), true);
}
}
| true |
445e522c5695ed66de0ae9a15027c24b7a316fdb | Rust | assert0/aoc20 | /src/days/day5.rs | UTF-8 | 1,742 | 3.359375 | 3 | [] | no_license | use std::fs;
use regex::Regex;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Seat {
id: usize,
}
impl Seat {
pub fn parse(line: &str) -> Seat {
lazy_static! {
static ref SEAT: Regex = Regex::new(r"^[FB]{7}[LR]{3}").unwrap();
}
assert!(SEAT.is_match(&line));
let... | true |
9b7162db1e4992d28debb8e441d36987833fb254 | Rust | myuon/ruyt | /src/materials.rs | UTF-8 | 6,527 | 2.9375 | 3 | [] | no_license | use crate::vector::*;
use crate::textures::*;
use crate::pdf::*;
#[derive(Clone)]
pub struct HitRecord {
pub at: f32,
pub point: V3,
pub normal: V3,
pub u: f32,
pub v: f32,
}
trait Material {
fn scatter(&self, ray_in: &Ray, hit_record: &HitRecord) -> ScatterRecord;
fn scattering_pdf(&self... | true |
2fd61c4b1b5659ef4c5ea00e30d2043817b036c2 | Rust | sdfgeoff/bevy | /crates/bevy_ecs/src/core/query.rs | UTF-8 | 23,654 | 2.625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | // Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in ... | true |
e724ae7ea145ea6151e3aa4a34beeba26b88849e | Rust | raygon-renderer/thermite | /crates/thermite/src/rng/mod.rs | UTF-8 | 1,160 | 2.59375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::*;
pub mod pcg32;
pub mod xoshiro;
pub trait SimdRng<S: Simd> {
fn reseed(&mut self, seed: Vu64<S>);
#[inline(always)]
fn next_u32(&mut self) -> Vu32<S> {
// use higher bits in cases where there is low linear complexity in low bits
(self.next_u64() >> 32).cast()
}
#[in... | true |
ecf408826c7314280dbc4ef832b7205deecd133f | Rust | ShibbyContinuum/macaroon_server | /src/servers/macaroon_server.rs | UTF-8 | 3,620 | 2.796875 | 3 | [] | no_license |
use super::key::Key;
use super::api::Api;
use std::net::TcpListener;
use std::net::Ipv4Addr;
use std::io::BufReader;
use std::io::Read;
use std::net::TcpStream;
use std::thread;
use macaroons::token::Token;
use macaroons::verifier::Verifier;
use rand::{ Rng, SeedableRng };
use rand::os::OsRng;
use rand::chacha::ChaC... | true |
6171651445debe7ec30050e167cbc8c3917811a2 | Rust | leontoeides/google_maps | /src/distance_matrix/request/with_arrival_time.rs | UTF-8 | 916 | 3.296875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use crate::distance_matrix::request::Request;
use chrono::NaiveDateTime;
impl<'a> Request<'a> {
/// Specifies the desired arrival time.
///
/// ## Arguments:
///
/// * `arrival_time` ‧ The time the passenger should arrive at their final
/// destination by.
///
/// ## Description:
/... | true |
4ba7fb5e897a8332e2ab2081180d177fb91fb924 | Rust | apoelstra/halfsleep | /src/mutator/mod.rs | UTF-8 | 1,520 | 2.828125 | 3 | [
"CC0-1.0"
] | permissive | // Half Sleep -- Mutation Testing for Rust
// Written in 2015 by
// Andrew Poelstra <apoelstra@wpsoftware.net>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed witho... | true |
d148361c0b31c1beb83a7bc9fc0e0e530a615f2a | Rust | llluiop/rust | /loop/src/main.rs | UTF-8 | 282 | 3.03125 | 3 | [] | no_license | fn main() {
for (count,element) in (15..20).enumerate() {
println!("count = {} and element = {}", count, element);
}
let lines = "hello\nworld".lines();
for (linenumber, line) in lines.enumerate() {
println!("{}: {}", linenumber, line);
}
}
| true |
735a7bbaa48b6a75a0073c40de78d6ac9510eca0 | Rust | IThawk/rust-project | /rust-master/src/test/ui/enum/enum-discrim-too-small.rs | UTF-8 | 957 | 3.296875 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | #[repr(u8)]
enum Eu8 {
Au8 = 23,
Bu8 = 223,
Cu8 = -23,
//~^ ERROR cannot apply unary operator `-` to type `u8`
}
#[repr(u16)]
enum Eu16 {
Au16 = 23,
Bu16 = 55555,
Cu16 = -22333,
//~^ ERROR cannot apply unary operator `-` to type `u16`
}
#[repr(u32)]
enum Eu32 {
Au32 = 23,
Bu32 ... | true |
41bad1fcc8229be007a1a46c5aa906c6c816bcad | Rust | soedirgo/sat-solver | /src/lib.rs | UTF-8 | 14,639 | 2.703125 | 3 | [
"Unlicense"
] | permissive | use num_rational::Ratio;
use ordered_float::OrderedFloat;
use priority_queue::PriorityQueue;
use std::cell::Cell;
use std::cell::RefCell;
use std::collections::HashMap;
use std::collections::HashSet;
use std::rc::Rc;
const BUMP_FACTOR: f64 = 1. / 0.95;
pub struct Solver {
literals: HashMap<i32, Rc<Lit>>,
wat... | true |
f71fca4581232916ab582a3688e9085e086d4ae1 | Rust | bytwise/mitte_amd64 | /src/ptr.rs | UTF-8 | 10,460 | 3.03125 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::ops;
use reg::Reg64;
mod private {
use common::{Rex, Args};
pub trait MemSealed: Clone + Rex + Args {}
impl<M> MemSealed for M where M: Clone + Rex + Args {}
}
pub trait Mem: private::MemSealed {}
impl Mem for Pointer {}
impl Mem for Ptr<(), (), i8> { }
impl Mem for Ptr<(), (), i32> {}
impl ... | true |
f84841236beee7b79dc838f5f9b5d558c94bbc80 | Rust | peanut996/Leetcode | /Rust/src/637. Average of Levels in Binary Tree.rs | UTF-8 | 1,507 | 3.359375 | 3 | [] | no_license | /*637. Average of Levels in Binary Tree
给定一个非空二叉树, 返回一个由每层节点平均值组成的数组.
示例:
输入:
3
/ \
9 20
/ \
15 7
输出: [3, 14.5, 11]
解释:
第0层的平均值是 3, 第1层是 14.5, 第2层是 11. 因此返回 [3, 14.5, 11].
注意:
节点值的范围在32位有符号整数范围内。
*/
use std::rc::Rc;
use std::cell::RefCell;
impl Solution {
pub fn average_of_levels(root: O... | true |
ae763bf762c551a90441a4357bde7bddd70dca8d | Rust | jairoandre/my-nannou | /sketches/doom/doom.rs | UTF-8 | 3,712 | 2.5625 | 3 | [] | no_license | use nannou::prelude::*;
use rand::Rng;
struct Model {
_pixels: Vec<Vec<usize>>,
_current: f32,
}
const COLOR_PALET: [(u8, u8, u8); 37] = [
(0, 0, 0),
(31, 7, 7),
(47, 15, 7),
(71, 15, 7),
(87, 23, 7),
(103, 31, 7),
(119, 31, 7),
(143, 39, 7),
(159, 47, 7),
(175, 63, 7),... | true |
81738e9232463a2336e217c562bf088f7ee0caaa | Rust | Brian3647/snake.rs | /src/cli.rs | UTF-8 | 919 | 3.140625 | 3 | [] | no_license | use std::process::exit;
use structopt::StructOpt;
pub fn get_args() -> Args {
Args::from_optargs(OptArgs::from_args())
}
#[derive(Debug, StructOpt)]
pub struct OptArgs {
#[structopt(short = "h", long = "height")]
pub height: Option<u16>,
#[structopt(short = "w", long = "width")]
pub width: Option<u16>
}
pub s... | true |
aeb167f1426a3a79362201223ea905ce4b0cb341 | Rust | owen8877/leetcode-rs | /src/problem_205.rs | UTF-8 | 592 | 3.125 | 3 | [] | no_license | pub fn is_isomorphic(s: String, t: String) -> bool {
let s: Vec<char> = s.chars().collect();
let t: Vec<char> = t.chars().collect();
use std::collections::*;
let mut map = HashMap::new();
let mut set = HashSet::new();
for (&cs, &ct) in s.iter().zip(t.iter()) {
if let Some(&ct_old) = ma... | true |
f3bf19ba6bc4359e210dc41411b3fbd7d7007ded | Rust | xpeerchain/xpeerchain | /language/vm/vm_runtime/src/value_serializer.rs | UTF-8 | 5,413 | 2.6875 | 3 | [
"Apache-2.0"
] | permissive | // Copyright (c) The XPeer Core Contributors
// SPDX-License-Identifier: Apache-2.0
use crate::{
loaded_data::{struct_def::StructDef, types::Type},
value::{MutVal, Value},
};
use canonical_serialization::*;
use failure::prelude::*;
use std::convert::TryFrom;
use types::{account_address::AccountAddress, byte_ar... | true |
afa0978df0de43f3f92536086604a64c808ac0af | Rust | mstange/gecko-profiler-demangle | /src/lib.rs | UTF-8 | 1,379 | 2.515625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | extern crate cpp_demangle;
extern crate msvc_demangler;
extern crate rustc_demangle;
extern crate wasm_bindgen;
use wasm_bindgen::prelude::*;
use msvc_demangler::DemangleFlags;
/// Takes an input string and runs it through a sequence of demanglers. Returns
/// the demangled string if a match was found, or the origin... | true |
ffb4619720b37dfb44403f8adc77d41eac4f7d9e | Rust | xshade-lang/xshade-parser | /src/parser/ws.rs | UTF-8 | 1,115 | 2.9375 | 3 | [
"MIT"
] | permissive | use nom::types::CompleteStr;
use nom_locate::LocatedSpan;
type NomSpan<'a> = LocatedSpan<CompleteStr<'a>>;
named!(pub ws0<NomSpan, NomSpan>, recognize!(many0!(one_of!(" \r\n\t"))));
named!(pub ws1<NomSpan, NomSpan>, recognize!(many1!(one_of!(" \r\n\t"))));
#[cfg(test)]
mod tests {
use super::*;
#[test]
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.