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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
034c7d72c76dc0dc209125fb3f43a004fba67169 | Rust | k0nserv/rusttracer | /src/config_loader.rs | UTF-8 | 3,279 | 2.828125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
use std::path::Path;
use std::rc::Rc;
use camera;
use color::Color;
use config;
use material;
use mesh_loader::MeshLoader;
use renderer;
use scene;
use texture;
pub struct ConfigLoader {
fallback_material: Rc<material::Material>,
named_textures: HashMap<String, Rc<dyn texture::T... | true |
638ed1e922c65d8431de998e1babdc384b760c59 | Rust | davidtraff/rmber | /backend/server/src/event_handlers.rs | UTF-8 | 4,221 | 2.6875 | 3 | [] | no_license | use std::io::{Error, ErrorKind};
use protocol::{PACKET_SCHEMA_ERR, PACKET_SUBSCRIPTION_ERR, PACKET_UPDATE_ERR, Packet, StringKey};
use crate::{
connection::Connection,
server::{
ConnectionErrorEvent, ConnectionEvent, EventContext, PacketEvent, PointUpdateEvent,
ServerErrorEvent,
},
};
pub... | true |
47682093c0481a4884f039130390a925efc6bd21 | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0202.happy-number/happy-number.go | UTF-8 | 301 | 3.125 | 3 | [
"MIT"
] | permissive | package problem0202
func isHappy(n int) bool {
slow, fast := n, trans(n)
for slow != fast {
slow = trans(slow)
fast = trans(trans(fast))
}
if slow == 1 {
return true
}
return false
}
func trans(n int) int {
res := 0
for n != 0 {
res += (n % 10) * (n % 10)
n /= 10
}
return res
}
| true |
4d324cd31ba58f647719d344715bd850ca5bed9d | Rust | solana-labs/rbpf | /fuzz/fuzz_targets/grammar_aware.rs | UTF-8 | 7,441 | 2.828125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | #![allow(dead_code)]
use solana_rbpf::insn_builder::{Arch, BpfCode, Cond, Endian, Instruction, MemSize, Source};
#[derive(arbitrary::Arbitrary, Debug, Eq, PartialEq)]
pub enum FuzzedOp {
Add(Source),
Sub(Source),
Mul(Source),
Div(Source),
BitOr(Source),
BitAnd(Source),
LeftShift(Source),
... | true |
d0e2fd132a50a345a40202a0dc6e63ec25022ff3 | Rust | makutak/sandbox | /tutorials/tour_of_rust/ch05/49.rs | UTF-8 | 1,143 | 3.8125 | 4 | [] | no_license | /*
`&mut` 演算子を使えば、リソースへの変更可能なアクセスを借用することもできる。
リソースの所有者は可変な借用の間は移動や変更ができない。
データ競合を防止するため、Rustでは同時に2つの変数から値を変更することはできない。
*/
struct Foo {
x: i32,
}
fn do_something(f: Foo) {
println!("{}", f.x);
// f はここでドロップ
}
fn main() {
let mut foo = Foo { x: 42 };
let f = &mut foo;
// 失敗: do_something(foo)... | true |
29bb7287a171a9a5c78a9afa577e0d95289aeaee | Rust | andrewnturner/ray_tracer | /src/main.rs | UTF-8 | 4,781 | 2.53125 | 3 | [] | no_license | mod geometry;
mod graphics;
mod render;
mod scenes;
mod util;
use std::fs::File;
use std::io::Write;
use std::path::Path;
use num::clamp;
use rand::{Rng, thread_rng};
use geometry::point::Point3;
use geometry::ray::Ray;
use geometry::vector::Vector3;
use graphics::colour::Colour;
use render::camera::Camera;
use rend... | true |
ec097b49545e9e88d6ab26869f36a07fbf8e24dc | Rust | yshui/briefly | /src/main.rs | UTF-8 | 17,609 | 2.6875 | 3 | [] | no_license | #![allow(clippy::single_match)]
use ::std::collections::HashMap;
use ::std::sync::Mutex;
use anyhow::Error;
use chrono::naive::NaiveDate as Date;
use derive_more::Display;
use log::*;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
mod citation;
mod filters;
mod github;
mod md;
lazy_static::lazy_static!... | true |
ec368848c51b5626f21a8b886c008255beea011c | Rust | rick68/rust-trace | /libcore/cmp/enum_Ordering/trait_PartialOrd/partial_cmp.rs | UTF-8 | 3,139 | 3.625 | 4 | [
"MIT"
] | permissive | #![feature(core)]
extern crate core;
#[cfg(test)]
mod tests {
use core::cmp::Ordering::{self, Less, Equal, Greater};
// #[derive(Clone, Copy, PartialEq, Debug)]
// #[stable(feature = "rust1", since = "1.0.0")]
// pub enum Ordering {
// /// An ordering where a compared value is less [than anoth... | true |
292e0f1ad39f5edc064a68a1662a955eaae74bac | Rust | lusamreth/my_first_cli_app | /src/file/mod.rs | UTF-8 | 14,938 | 2.625 | 3 | [] | no_license | /* File_config_functionalities_pmz */
// conditions:
/*
exec trait: [alias:(file/any)] [operations] [path/name] [parameters/--options]
Read:Content _ none
Write:Content _ String : if use multi line content ->
check len()::Enum -> i32|&str
Update:Content _ String
... | true |
cd62ae2107a74b4a8ba46b804eb03c59d75ab36c | Rust | KeyMaster-/Fotoleine | /src/worker_pool.rs | UTF-8 | 2,346 | 3.265625 | 3 | [
"MIT"
] | permissive | use std::sync::mpsc::{Sender, Receiver, channel};
use std::sync::{Arc, Mutex};
use std::thread::{self, JoinHandle};
pub struct WorkerPool<W: Worker + 'static + Send> {
pub output: Receiver<W::Output>,
worker_threads: Vec<Option<JoinHandle<()>>>,
task_sender: Sender<TaskMessage<W>>
}
pub trait Worker {
type Inp... | true |
d32a6b0b2735d51bdd01d771cbe9334dbc36b3cc | Rust | djsxut/tokio-cn-doc | /src/bin/mini-tokio-one.rs | UTF-8 | 1,453 | 2.96875 | 3 | [
"MIT"
] | permissive | use std::collections::VecDeque;
use std::future::Future;
use std::pin::Pin;
use std::task::Context;
use futures::task;
use std::option::Option::Some;
use std::time::{Instant, Duration};
mod common;
use common::delay::Delay;
/// mini-tokio 第一版
fn main() {
let mut mini_tokio = MiniTokio::new();
mini_tokio.spa... | true |
de21c5f200395bfd4f9ed9b6d5d88cf457f4bee8 | Rust | GodOfProgramming/ltt | /rust/test/tutorial/ch15/messenger/src/lib_tests.rs | UTF-8 | 675 | 2.921875 | 3 | [] | no_license | use super::*;
use std::cell::RefCell;
struct MockMessenger {
sent_messages: RefCell<Vec<String>>,
}
impl MockMessenger {
fn new() -> MockMessenger {
MockMessenger {
sent_messages: RefCell::new(vec![]),
}
}
}
impl Messenger for MockMessenger {
fn send(&self, message: &str) ... | true |
ab87bbe2310ab53edd717cd567ebd8bc5a141e74 | Rust | jmou/aoc2018 | /d03/src/bin/p2.rs | UTF-8 | 2,300 | 3.390625 | 3 | [] | no_license | use std::io::{self, BufRead};
use std::iter::Peekable;
struct Claim {
id: usize,
left: usize,
top: usize,
width: usize,
height: usize,
}
fn consume_str<T>(iter: &mut T, s: &str)
where
T: Iterator<Item = char>,
{
for c in s.chars() {
if iter.next() != Some(c) {
panic!("m... | true |
0d309d8db40131d45518b70236067129a8f91ac5 | Rust | kanagasabai-Hub/rust-programs-practised | /archives/rust program archives traits.rs | UTF-8 | 2,611 | 3.515625 | 4 | [] | no_license | // sample and test programs
use std::io;
trait Sounds {
// add code here
fn make_sound(&self);
}
#[derive(Debug)]
struct Cat {
sounds: String,
}
struct Tiger {
sounds: String,
}
impl Cat {
fn new(snd: String) -> Cat {
Cat { sounds: snd }
}
fn called(&self) {
on_scare(se... | true |
50d8ae2700abd2cb8ba4850c6b9ec1791f070de8 | Rust | sria91-rlox/rlox-36 | /src/lexer.rs | UTF-8 | 10,904 | 2.984375 | 3 | [
"MIT"
] | permissive | use {
std::{
fmt,
io::{
self,
prelude::*,
},
},
byteorder::ReadBytesExt as _,
crate::error::{
Error,
Result,
},
};
pub(crate) use self::Token::*;
pub(crate) struct Lexer<'a> {
peek: Option<u8>,
stream: Option<Box<dyn Read + 'a>... | true |
cedfbcba9825968fa0763f986e9c3cf17088b2f4 | Rust | ZornHuang-Crypto/LearnRust | /reference_counter/thinking_questions/src/main.rs | UTF-8 | 451 | 3.71875 | 4 | [] | no_license | /* 思考题一
use std::thread;
fn main() {
let arr = vec![1];
let handle = thread::spawn(move || {
println!("arr: {:?}", arr);
});
handle.join().unwrap();
}
*/
use std::thread;
use std::sync::Arc;
fn main() {
let str = Arc::new("Hello CR");
let v = Arc::clone(&str);
let handle = thread... | true |
dcb28fb82cebd689e82bb7627f597f2514159100 | Rust | chaosprint/glicol | /rs/synth/src/node/effect/reverb.rs | UTF-8 | 2,483 | 2.71875 | 3 | [
"MIT"
] | permissive | use crate::{Buffer, Input, Node, BoxedNodeSend, NodeData, Message};
use freeverb::*;
use hashbrown::HashMap;
use petgraph::graph::NodeIndex;
pub struct Reverb<const N: usize> {
fv: freeverb::Freeverb,
input_order: Vec<usize>,
}
impl<const N: usize> Reverb<N> {
pub fn new() -> Self {
let fv = free... | true |
d05aa323c0c433d1afa41dc97ad992d04d5312f8 | Rust | jonlamb-gh/elis-lib | /src/invoice_summary.rs | UTF-8 | 1,604 | 2.78125 | 3 | [] | no_license | use steel_cent::currency::USD;
use steel_cent::Money;
use money_serde::MoneyDef;
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct InvoiceSummary {
total_pieces: usize,
#[serde(with = "MoneyDef")]
estimated_shipping_cost: Money,
#[serde(with = "MoneyDef")]
sub_total_cost: Money,
#[ser... | true |
84623dd14e2a4193d5716a1712ae02d86914b015 | Rust | dialtone/protostore2 | /src/aio.rs | UTF-8 | 16,681 | 2.578125 | 3 | [
"MIT"
] | permissive | use std::default::Default;
use std::io;
use std::thread::{self, JoinHandle};
use std::time::SystemTime;
use mio;
use core::pin::Pin;
use futures::channel::{mpsc, oneshot};
use futures::executor;
use futures::stream::Stream;
use futures::task::Context;
use futures::{Future, Poll};
use bytes::BytesMut;
use eventfd::Ev... | true |
d1a048b053101b86fdc06efbc419ad12b2ef8cbe | Rust | LaurentMazare/tch-rs | /src/nn/var_store.rs | UTF-8 | 36,688 | 3.03125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Variable stores.
use super::Init;
use crate::tensor::Tensor;
use crate::wrappers::stream::ReadSeekAdapter;
use crate::{Device, Kind, TchError};
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::collections::HashMap;
use std::io::{Read, Seek};
use std::ops::Div;
use std::sync::{Arc, Mutex, MutexGua... | true |
93226c0bedd9605b889dfdb1a0d04028f8b278ed | Rust | TommyCpp/monolith | /src/common/time_point.rs | UTF-8 | 1,678 | 2.96875 | 3 | [
"MIT"
] | permissive | use crate::proto::Sample;
use crate::{Timestamp, Value};
use failure::_core::cmp::Ordering;
const F64_MARGIN: f64 = 0.000000001;
#[derive(Clone, Debug)]
pub struct TimePoint {
pub timestamp: Timestamp,
pub value: Value,
// How do we organize the metadata
}
impl TimePoint {
pub fn new(timestamp: Ti... | true |
f0cb30780f9f8ab7532e660462576ad0db8b29c2 | Rust | des256/e | /build.rs | UTF-8 | 6,741 | 2.734375 | 3 | [
"MIT"
] | permissive | use {
std::{
env,
fs,
process,
path,
},
};
// define the possible main configuration branches of the code
pub enum System {
Linux,
Windows,
Macos,
Android,
Ios,
Web,
}
fn main() {
// make current build available to source code
println!("cargo:ru... | true |
63634a87474828d0de15735f9586b7d833dba4f3 | Rust | tuxmark5/north | /north_core/src/iter/borrow_nodes.rs | UTF-8 | 1,071 | 2.546875 | 3 | [] | no_license |
use {
crate::{
Model, Node,
iter::ModelIterator,
node_id::ToNodeId,
structure::storage::StorageExt,
},
std::{
cell::Ref,
marker::PhantomData,
},
};
////////////////////////////////////////////////////////////////////////////////////////////////
pub struct BorrowNodes<'m, I> {
inner:... | true |
ea4e39d3860f887cc4a8ffed763cfe66c9a8ffd4 | Rust | bitemyapp/shiftrss | /src/lib.rs | UTF-8 | 3,743 | 3.296875 | 3 | [] | no_license | extern crate rss;
use std::fs::File;
use std::io::BufReader;
use rss::Channel;
use rss::Item;
pub fn open_rss_file(filename: String, item_filter: ItemFilter) {
let file = File::open(filename).unwrap();
let mut channel = Channel::read_from(BufReader::new(file)).unwrap();
filter_feed(&mut channel, item_filt... | true |
76e93f028eeceb06b8d621df1ba728d49800c2c7 | Rust | nabijaczleweli/poke-a-mango | /src/ops/state.rs | UTF-8 | 7,182 | 3.375 | 3 | [
"MIT"
] | permissive | //! Manual `GameState` manipulation, to be used when implementing a UI.
//!
//! For a UI implementing the use of this see the implementation of `Widgets::update()`.
use self::super::{Difficulty, GameState};
use self::super::super::util::FRUITS;
use rand::{Rng, thread_rng};
use std::mem;
/// Press the Start button i... | true |
1b0a2e385a0890a6f14ba79f9fe7bcfdecb4c5e1 | Rust | IThawk/rust-project | /rust-master/src/test/ui/print_type_sizes/variants.rs | UTF-8 | 575 | 2.640625 | 3 | [
"MIT",
"LicenseRef-scancode-other-permissive",
"Apache-2.0",
"BSD-3-Clause",
"BSD-2-Clause",
"NCSA"
] | permissive | // compile-flags: -Z print-type-sizes
// build-pass (FIXME(62277): could be check-pass?)
// This file illustrates two things:
//
// 1. Only types that appear in a monomorphized function appear in the
// print-type-sizes output, and
//
// 2. For an enum, the print-type-sizes output will also include the
// size o... | true |
d10010514acbc3a4fbe475e8fb54ff6f850bad29 | Rust | gilbertw1/winit | /examples/grabbing.rs | UTF-8 | 1,768 | 2.703125 | 3 | [
"Apache-2.0"
] | permissive | extern crate winit;
use winit::{ControlFlow, WindowEvent, ElementState, KeyboardInput};
fn main() {
let mut events_loop = winit::EventsLoop::new();
let window = winit::WindowBuilder::new().build(&events_loop).unwrap();
window.set_title("winit - Cursor grabbing test");
let mut grabbed = false;
i... | true |
c04ba70b09ce65f68fde34e6cd622c37bf1599b4 | Rust | akrisrn/leet-code-rust | /src/solution/easy/p0001_two_sum.rs | UTF-8 | 1,917 | 3.859375 | 4 | [] | no_license | use std::collections::HashMap;
use crate::Solution;
/// https://leetcode.com/problems/two-sum/
///
/// Given an array of integers, return **indices** of the two numbers such that they add up to a specific target.
/// You may assume that each input would have **exactly** one solution, and you may not use the same elem... | true |
a16006c80d5458497cac6e84eb333c9d1ae579ec | Rust | szabgab/slides | /rust/examples/functions/recursive_fibonacci.rs | UTF-8 | 288 | 3.828125 | 4 | [] | no_license | fn main() {
for n in 1..10 {
let fibo = fibonacci(n);
println!("The {n}th Fibonacci number is {fibo}");
}
}
fn fibonacci(n:i32) -> i32 {
if n == 0 {
return 1;
}
if n == 1 {
return 1;
}
return fibonacci(n-1) + fibonacci(n-2);
}
| true |
6cee8ce7230bf77833c4bc38972beaf1f66cc8d7 | Rust | alexgenco/exercisms | /rust/beer-song/src/lib.rs | UTF-8 | 863 | 3.390625 | 3 | [] | no_license | pub fn verse(num: usize) -> String {
match num {
0 => "No more bottles of beer on the wall, no more bottles of beer.\nGo to the store and buy some more, 99 bottles of beer on the wall.\n".to_owned(),
1 => "1 bottle of beer on the wall, 1 bottle of beer.\nTake it down and pass it around, no more bott... | true |
c3e81addeb71d497de1dae5cc1d741b33c1d614d | Rust | nataliajsilva/algoritmos | /atividade-20/src/main.rs | UTF-8 | 1,852 | 3.90625 | 4 | [] | no_license | /*Elaborar um programa que leia dois vetores (denominados A e B) com 5 elementos reais. Construir um vetor denominado C, onde cada elemento deverá corresponder a subtração do elemento correspondente do vetor A com um elemento correspondente do vetor B. Ao final, apresentar os elementos do vetor C.*/
use std::io;
fn ... | true |
654f6f438a0e24a522550112b2b2a4595b579334 | Rust | yan0327/reasonthree | /reasonfour-1/src/main.rs | UTF-8 | 638 | 3.75 | 4 | [] | no_license | trait LightTime{
fn time(&self) -> u8 ;
}
enum TrafficLight{
Red,
Green,
Yellow,
}
impl LightTime for TrafficLight {
fn time(&self) -> u8{
let output = match self{
TrafficLight::Red => 60,
TrafficLight::Green => 75,
TrafficLight::Yellow => 3,
}... | true |
f9cb9223a41fb46144d6ca5c083b507259a44165 | Rust | steveklabnik/crossterm | /src/kernel/windows_kernel/cursor.rs | UTF-8 | 2,647 | 3 | 3 | [
"MIT"
] | permissive | //! This module handles some logic for cursor interaction in the windows console.
use winapi::shared::minwindef::{FALSE, TRUE};
use winapi::um::wincon::{
SetConsoleCursorInfo, SetConsoleCursorPosition, CONSOLE_CURSOR_INFO, COORD,
};
use super::{csbi, handle, kernel};
use std::io;
/// This stores the cursor pos, ... | true |
727d8eb0b0c78d2c4caa6e9a9b9d71b8e8136956 | Rust | olivereanderson/safari_stats | /user-stats/src/configuration.rs | UTF-8 | 2,588 | 3.09375 | 3 | [] | no_license | use std::{path::PathBuf, str::FromStr};
use common_utils::date_utils::DateStamp;
/// Configuration for storage of FST sets describing the top 10 number of pics in sessions a user had on a given date.
pub struct SavedFstSetFilesConfig;
impl SavedFstSetFilesConfig {
/// The path to the directory where we serialize... | true |
3ac78415f1ed3ad6c6417df70e1a18a317730ab0 | Rust | edge-analytics/fpga-sleep-tracker | /host/src/data.rs | UTF-8 | 3,969 | 2.890625 | 3 | [
"MIT"
] | permissive | //! Data types and conversions.
use fixed::types::{I16F16, I1F7};
use serde::{Deserialize, Serialize};
use crate::{error::FpgaDriverError, traits::Data, FpgaDriverResult};
/// Number of input elements for sleep model.
pub const INPUT_NELEM_SLEEP: usize = 3;
/// Number of output elements for sleep model.
pub const OU... | true |
78ce287dd26ebd01945af654189f40b78444f15f | Rust | rust-embedded/cortex-m | /src/register/apsr.rs | UTF-8 | 1,130 | 3 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | //! Application Program Status Register
#[cfg(cortex_m)]
use core::arch::asm;
/// Application Program Status Register
#[derive(Clone, Copy, Debug)]
pub struct Apsr {
bits: u32,
}
impl Apsr {
/// Returns the contents of the register as raw bits
#[inline]
pub fn bits(self) -> u32 {
self.bits
... | true |
517b58908bb3be668b5227368360da1bdb6a202e | Rust | mesalock-linux/crates-sgx | /vendor/tiff/src/encoder/writer.rs | UTF-8 | 2,903 | 2.9375 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use error::TiffResult;
use byteorder::{BigEndian, ByteOrder, LittleEndian, NativeEndian, WriteBytesExt};
use std::io::{self, Seek, SeekFrom, Write};
pub trait TiffByteOrder: ByteOrder {
fn write_header<W: Write>(writer: &mut TiffWriter<W>) -> TiffResult<()>;
}
impl TiffByteOrder for LittleEndian {
fn write_he... | true |
5732f98e044adbb2d427b1d15fc6d54241f81a9a | Rust | robarnold/cryptopals | /src/s2c16.rs | UTF-8 | 2,044 | 2.640625 | 3 | [] | no_license | #[test]
fn challenge() {
use oracle;
use oracle::{DecodableOracle, Oracle};
use rand;
use std::str;
use util;
const MAGIC_STRING: &str = ";admin=true;";
let iv = util::gen_random_bytes(&mut rand::thread_rng(), 16);
let o = oracle::QuoteBytes::new(
oracle::ConstantAppend::new(
oracle::ConstantP... | true |
a01be50143420900a3214abad9f70eabbcb83ad7 | Rust | redox-os/orbtk | /orbtk_core/src/event/event_queue.rs | UTF-8 | 3,858 | 3.15625 | 3 | [
"MIT",
"CC-BY-4.0",
"Apache-2.0"
] | permissive | use std::any::{Any, TypeId};
use dces::prelude::Entity;
use super::{Event, EventStrategy};
#[derive(Debug)]
pub enum EventError {
WrongType(TypeId),
}
/// Internal wrapper for an event, including the strategy and source entity.
#[derive(Debug)]
pub struct EventBox {
event: Box<dyn Any + Send>,
event_typ... | true |
fec26884613445b0b7277021bfdbe1ae601d38f0 | Rust | Dgame/mysh | /src/path.rs | UTF-8 | 2,955 | 2.953125 | 3 | [] | no_license | use crate::pool::Pool;
use std::collections::HashMap;
use std::ffi::OsString;
use std::io;
use std::path::{Path, PathBuf};
fn read_files<P: AsRef<Path>>(dir: P) -> io::Result<HashMap<String, PathBuf>> {
use std::fs;
let mut files = HashMap::new();
for entry in fs::read_dir(dir)? {
if let Ok(entry)... | true |
ea17c1a5da6f7e1a259e85ab7d1d91f04af07190 | Rust | notdijon/hexavalent | /src/macros.rs | UTF-8 | 569 | 2.765625 | 3 | [
"MIT"
] | permissive | use std::mem::ManuallyDrop;
macro_rules! defer {
($action:expr) => {
let _defer = crate::macros::RunOnDrop::new(move || {
$action;
});
};
}
pub(crate) struct RunOnDrop<F: FnOnce()>(ManuallyDrop<F>);
impl<F: FnOnce()> RunOnDrop<F> {
pub(crate) fn new(f: F) -> Self {
Sel... | true |
4fc63e566b15b1bbe26e286fb6c5b2b3024a7d05 | Rust | b-vennes/generate-resume | /src/main.rs | UTF-8 | 2,652 | 3.25 | 3 | [] | no_license | extern crate markdown;
use std::{env, fs, path::Path};
use regex::Regex;
enum ReadError {
IO(String),
FileNotFound
}
fn read_from_file(path: String) -> Result<String, ReadError> {
let file_path = Path::new(&path);
let output = match file_path.is_file() {
true => match fs::read_to_string(file... | true |
8674877de125d71559eb3bc383442dd45f03453c | Rust | WeAreRust/Nes | /nes/src/cpu/instruction/php.rs | UTF-8 | 1,010 | 2.75 | 3 | [
"MIT"
] | permissive | use cpu::{
instruction::{ExtraCycle, Instruction},
operation::Operation,
Core,
};
use memory::WriteAddr;
/// Push processor status onto stack
///
/// Flags affected: None
#[inline(always)]
fn php(core: &mut Core, memory: &mut WriteAddr) {
core.push_stack(memory, core.reg.status.into());
}
/// Push processor s... | true |
fca903a6b32d0f0d5fe8911336257b1c928c87ca | Rust | blguru20/RustBasics | /rust/match_operaror/src/main.rs | UTF-8 | 623 | 3.5 | 4 | [] | no_license | fn main() {
let num = 1;
match num {
1 => println!("number 1"),
2 => println!("number 2"),
_ => println!("number not 1 or 2"), // equivalent to default??
}
let another_num = 8;
match another_num {
1 => println!("number 1"),
2 => println!("number 2"),
... | true |
21cf47fed28a9bebab40b1b3edcb7aaa7609d04e | Rust | bostonbell/SeqMe | /src/instrumentation/interface/instrument.rs | UTF-8 | 3,729 | 3.109375 | 3 | [] | no_license | pub mod Instrument
{
use sequencing::tonation::note::NoteCollections::RawNote;
pub trait PlayableInstrument
{
fn play(&mut self, &RawNote);
}
}
pub mod InstrumentWrapper
{
use sequencing::tonation::note::NoteCollections::RawNote;
use instrumentation::interface::instrument::Instrument;... | true |
a5d958aa6efe7b1e7d8f2f5759eef2efe466fce7 | Rust | Creckle/amethyst | /amethyst_renderer/src/cam.rs | UTF-8 | 2,355 | 3.671875 | 4 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Camera type with support for perspective and orthographic projections.
use cgmath::{Deg, Matrix4, Ortho, PerspectiveFov, Point3, Vector3};
/// The projection mode of a `Camera`.
///
/// TODO: Remove and integrate with `Camera`.
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize)]
pub enum Projection {
/... | true |
5a8a1c6c37e4b726e5a00bf08ab3b4b389b6b11a | Rust | bxq2011hust/WorkSpace | /codes/rust/liquid_contract/hello_world/lib.rs | UTF-8 | 3,441 | 3.65625 | 4 | [
"MIT"
] | permissive | #![cfg_attr(not(feature = "std"), no_std)]
use liquid_lang as liquid;
/// This declaration aims at importing `format!` macro used by `get` method.
/// If you don't need that, just remove this declaration freely.
#[macro_use]
extern crate alloc;
#[liquid::contract(version = "0.1.0")]
mod hello_world {
use liquid_... | true |
d511d2360ba118b1b40792b7d36a995dd4d9ed8e | Rust | niklasad1/dirs-rs | /src/macos.rs | UTF-8 | 2,419 | 2.671875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::env;
use std::path::PathBuf;
use std::mem;
use std::ptr;
use std::ffi::CStr;
use std::ffi::OsString;
use std::os::unix::ffi::OsStringExt;
extern crate libc;
pub fn home_dir() -> Option<PathBuf> {
return env::var_os("HOME").and_then(|h| { if h.is_empty() { None } else { Some(h) } } ).or_else(|| unsafe {
... | true |
ca2151281d81a2311b64bc422f4d3e66d1523778 | Rust | hpfeeds/broker | /src/frame.rs | UTF-8 | 5,264 | 3.390625 | 3 | [
"MIT"
] | permissive | //! Provides a type representing a Redis protocol frame as well as utilities for
//! parsing frames from a byte array.
use bytes::{Buf, Bytes};
use std::convert::TryInto;
use std::fmt;
use std::io::Cursor;
use std::num::TryFromIntError;
use std::string::FromUtf8Error;
/// A frame in the Redis protocol.
#[derive(Clone... | true |
d570743ed3ce67157f371b83a1711d14f77d4274 | Rust | JoJoJet/type-cli | /type-cli/src/args.rs | UTF-8 | 1,610 | 3.109375 | 3 | [] | no_license | use std::{convert::AsRef, str::FromStr};
use super::{Error, ArgRef};
use std::error::Error as StdError;
pub trait Argument : Sized {
fn parse(arg: impl AsRef<str>, arg: ArgRef) -> Result<Self, Error>;
}
impl<T: FromStr> Argument for T
where <T as FromStr>::Err : StdError + 'static
{
fn parse(val: impl AsRef<s... | true |
abb24e5a68a881d04f1ecef7f3680450bab87a47 | Rust | briangreenery/cryptopals | /3.block-and-stream/8.mersenne-stream-cipher/src/main.rs | UTF-8 | 2,576 | 3.046875 | 3 | [] | no_license | #![allow(dead_code)]
mod pals;
extern crate crypto;
extern crate rand;
extern crate time;
use rand::Rng;
struct MT19937Stream {
mt: pals::MT19937,
buffer: [u8; 4],
index: usize,
}
impl MT19937Stream {
fn new(seed: u16) -> MT19937Stream {
MT19937Stream {
mt: pals::MT19937::new(see... | true |
fa80cee132f4e7dda576be0a90d97e8b99742adc | Rust | denislobanov/rustygenmo | /src/train/analyse.rs | UTF-8 | 2,697 | 3.15625 | 3 | [] | no_license | use std::collections::{HashMap, HashSet};
use std::fmt::Display;
fn clean_word(w: &str) -> String {
return w.to_ascii_lowercase()
.trim()
.replace("''", "\"")
.trim_matches(|c: char| !c.is_alphabetic())
.to_string();
}
pub fn create_corpus(corpus: &str) -> Vec<String> {
return ... | true |
82bc1c8a21b60dbeeee33c511bcf448e92c559d3 | Rust | efrees/adventofcode2018 | /src/solutions/day3.rs | UTF-8 | 1,566 | 2.890625 | 3 | [] | no_license | use regex::Regex;
use std::collections::*;
pub fn solve() {
println!("Day 3");
let mut grid = vec![[0; 1000]; 1000];
let mut last_drawn = vec![[0; 1000]; 1000];
let mut non_overlapped_ids = HashSet::<i32>::new();
let lines = adventlib::read_input_lines("day3input.txt");
let re = Regex::new(r... | true |
01e5dd7d67535439f0f0abefd4c36273848541be | Rust | min4builder/craft-server | /src/world/block.rs | UTF-8 | 444 | 2.78125 | 3 | [] | no_license | pub type BlockId = u8;
#[derive(Copy, Clone, Debug)]
pub struct Block {
pub matter: BlockId,
}
impl Block {
pub const AIR: Block = Block { matter: 0 as BlockId };
pub const DARK_STONE: Block = Block { matter: 1 as BlockId };
pub const WATER: Block = Block { matter: 2 as BlockId };
pub const LIGHT_... | true |
20693fca03522b849dbf29c745e5a641a2a88cbf | Rust | dmikusa/pc4d-rust | /src/bin/auth/main.rs | UTF-8 | 826 | 2.5625 | 3 | [] | no_license | use sodiumoxide::crypto::auth;
use std::env;
fn main() {
if env::args().count() != 2 {
println!("Usage: {} plaintext", env::args().nth(0).unwrap());
println!(" plaintext: unencrypted data");
std::process::exit(1);
}
sodiumoxide::init().expect("Cannot initialize Sodium Oxide/libs... | true |
d3c91b73f88226c1ee51c084738434d6d42c8a76 | Rust | kopsteve/roapi | /columnq/src/io/mod.rs | UTF-8 | 2,663 | 3.203125 | 3 | [
"Apache-2.0"
] | permissive | use std::convert::TryFrom;
pub mod fs;
pub mod http;
pub mod memory;
pub mod s3;
use crate::error::ColumnQError;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum BlobStoreType {
Http,
S3,
FileSystem,
Memory,
}
impl TryFrom<Option<&uriparse::Scheme<'_>>> for BlobStoreType {
type Error = ColumnQErr... | true |
e596c3cac8d935dd1d3cdc9d197ebf0411084c34 | Rust | jamesmarva/Head-First-Rust | /ch21/s5/d4/src/main.rs | UTF-8 | 832 | 3.734375 | 4 | [] | no_license | use std::iter::Iterator;
use std::fmt::Display;
/// 这里要注意,
/// 这个mut 是表示iter 这个变量是可以被重复赋值,
/// 或者就是表示这个变量指向的内存是可以被修改
fn use_iter<ITEM, ITER> (mut iter: ITER)
where ITER: Iterator<Item=ITEM>,
ITEM: Display
{
while let Some(i) = iter.next() {
println!("{}", i)
}
}
fn new_iter<ITER>(mut iter... | true |
d2edb5a0386f6d64217860c3fd9c1cb96744a96a | Rust | pingzing/advent-of-code-2018 | /day_2/part_2/src/main.rs | UTF-8 | 1,396 | 3.453125 | 3 | [] | no_license | use std::fs::File;
use std::io::{BufRead, BufReader};
use std::collections::HashMap;
fn main() {
let input_file = File::open("input.txt").unwrap();
let file_reader = BufReader::new(input_file);
let all_lines: Vec<String> = file_reader.lines().map(|x| x.unwrap()).collect();
let (box1, box2) = find_... | true |
68625ad1296ca50f9a9919f928ceaeeaf94e2015 | Rust | leshow/flappy_bird | /src/actors.rs | UTF-8 | 3,329 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::{assets::Assets, util::vec_from_angle};
use ggez::{
nalgebra as na,
nalgebra::{Point2, Vector2},
};
use rand::Rng;
// bit of a useless trait right now
pub trait Actor {
fn new() -> Self;
fn update_pos(&mut self, dt: f32);
}
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub struct Player {... | true |
539343606b35a267a87744529566944d989ae5d8 | Rust | jedisct1/rust-openssl | /openssl/src/x509/tests.rs | UTF-8 | 3,896 | 2.59375 | 3 | [
"OpenSSL",
"MIT",
"LicenseRef-scancode-openssl",
"LicenseRef-scancode-ssleay-windows",
"Apache-2.0"
] | permissive | use serialize::hex::FromHex;
use std::io;
use std::path::Path;
use std::fs::File;
use crypto::hash::Type::{SHA256};
use crypto::pkey::PKey;
use x509::{X509, X509Generator};
use x509::extension::Extension::{KeyUsage,ExtKeyUsage,SubjectAltName,OtherNid,OtherStr};
use x509::extension::AltNameOption as SAN;
use x509::exte... | true |
ad18faccaca3dd333170affe4aae51a100bd211d | Rust | WalrusCodes/adv2020 | /src/day3.rs | UTF-8 | 1,228 | 3.78125 | 4 | [] | no_license | // Traverses the map, returns number of trees encountered.
fn traverse(map: &Vec<&str>, dx: usize, dy: usize) -> u32 {
let width = map[0].len();
let mut x = 0;
let mut y = 0;
let mut cnt = 0;
while y < map.len() {
let ch = map[y].chars().nth(x).unwrap();
if ch == '#' {
//... | true |
3b19c4354f9ea78aaf77d3f5d3ab778d5133e3d4 | Rust | MarkTseng/kernel | /src/scheme/env.rs | UTF-8 | 6,881 | 2.625 | 3 | [
"MIT"
] | permissive | use alloc::arc::Arc;
use alloc::{BTreeMap, Vec};
use core::{cmp, str};
use core::sync::atomic::{AtomicUsize, Ordering};
use spin::{Mutex, RwLock};
use context;
use syscall::data::Stat;
use syscall::error::*;
use syscall::flag::{MODE_FILE, SEEK_SET, SEEK_CUR, SEEK_END, O_CREAT};
use syscall::scheme::Scheme;
#[derive(C... | true |
993f22d2c57b5cc7e70e3aa8f88c6cfc41f4990e | Rust | qoollo/pearl | /src/blob/core.rs | UTF-8 | 21,338 | 2.5625 | 3 | [
"MIT"
] | permissive | use std::time::SystemTime;
use bytes::{BufMut, Bytes, BytesMut};
use tokio::time::Instant;
use crate::error::ValidationErrorKind;
use crate::filter::{CombinedFilter, FilterTrait};
use crate::storage::{BlobRecordTimestamp, ReadResult};
use super::prelude::*;
use super::{header::Header, index::IndexTrait};
pub(crate... | true |
2ee1b7b46fa16689a2d3d491f7cfc4e94bc7a11e | Rust | filipdulic/bus-queue | /examples/async-simple.rs | UTF-8 | 715 | 2.640625 | 3 | [] | no_license | use bus_queue::flavors::arc_swap::async_bounded;
use futures::executor::block_on;
use futures::stream::{iter, StreamExt};
fn main() {
let (publisher, subscriber1) = async_bounded(10);
let subscriber2 = subscriber1.clone();
block_on(async move {
iter(1..15).map(|i| Ok(i)).forward(publisher).await.u... | true |
e546e3b14afbc8981dd66b77d72e34bf56a5850e | Rust | JulianSchmid/etherparse | /etherparse/tests/internet/ipv4_extensions.rs | UTF-8 | 14,378 | 2.5625 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use super::super::*;
use crate::ip_number::*;
use std::io::Cursor;
pub mod header {
use super::*;
#[test]
fn from_slice() {
let auth_header = IpAuthHeader::new(UDP, 0, 0, &[]).unwrap();
let buffer = {
let mut buffer = Vec::with_capacity(auth_header.header_len());
... | true |
5253c334f0993c83145453a99b254f2ca4b3aea4 | Rust | softprops/par | /src/lib.rs | UTF-8 | 7,647 | 3.65625 | 4 | [
"MIT"
] | permissive | //! par is a terminal interface for rendering progress bars
//!
//! #example
//! ```rust
//! use par::Bar;
//! fn main() {
//! let bar = Bar::new(100);
//! for i in 1..101 {
//! bar.add(i);
//! std::thread::sleep_ms(10);
//! }
//! bar.finish_print("done")
//! }
//! ```
extern crate capsi... | true |
dc118f6099338148dfab2022087e87bd64999190 | Rust | frjonsen/devdiary-backend | /src/entities/session.rs | UTF-8 | 446 | 2.59375 | 3 | [] | no_license | #[derive(Serialize, Deserialize, Debug, PartialEq)]
pub struct Session {
pub token: String
}
impl ::iron_sessionstorage::Value for Session {
fn get_key() -> &'static str {
"session_token"
}
fn into_raw(self) -> String {
self.token
}
fn from_raw(value: String) -> Option<Self> {... | true |
bc12d30e5dc915b5eebc99c933a3f2d6fc9de679 | Rust | bouzuya/rust-atcoder | /cargo-atcoder/contests/arc015/src/bin/b.rs | UTF-8 | 767 | 2.890625 | 3 | [] | no_license | use proconio::input;
fn main() {
input! {
n: usize,
t: [(f64, f64); n]
};
let mut counts = vec![0; 6];
for (max_t_i, min_t_i) in t {
if 35_f64 <= max_t_i {
counts[0] += 1;
}
if 30_f64 <= max_t_i && max_t_i < 35_f64 {
counts[1] += 1;
... | true |
7db7a542d8818cf8a973d13f79b130310c5a9240 | Rust | Quantum-Desmond/Advent-of-Code-2018 | /src/aoc_problems/day_15.rs | UTF-8 | 20,149 | 3.25 | 3 | [] | no_license | use std::cmp;
use std::error::Error;
use std::fmt;
use std::fs::File;
use std::io;
use std::io::prelude::*;
use std::result;
use std::str::FromStr;
use std::collections::{BTreeMap, BTreeSet, VecDeque};
macro_rules! err {
($($tt:tt)*) => { Err(Box::<dyn Error>::from(format!($($tt)*))) }
}
type Result<T> = result:... | true |
90c314c25550aa171d35ebd523dbef71715e1657 | Rust | ives9638/hadron | /hadrond/_src/ctl_raft/macros.rs | UTF-8 | 2,236 | 2.875 | 3 | [
"Apache-2.0"
] | permissive | /// Unpack a result, emitting errors over a specific channel, and returning the Ok value on success.
#[macro_export]
macro_rules! ok_or_else_tx_err {
($matcher:expr, $holder:ident) => {
match $matcher {
Ok(val) => val,
Err(err) => {
tracing::error!(error = ?err);
... | true |
cade9d556ff1d859ec66a883cfa430c4bf488621 | Rust | kerlw/monkey_rust | /src/lexer/test.rs | UTF-8 | 3,263 | 3.359375 | 3 | [] | no_license | use crate::lexer::lexer::Lexer;
use crate::lexer::token::Token;
#[test]
fn sign_test() {
let mut lx = Lexer::new("={}[]+;");
let expects: Vec<Token> = vec![
Token::Assign,
Token::LBrace,
Token::RBrace,
Token::LBracket,
Token::RBracket,
Token::Plus,
Token:... | true |
565fabb6adf625b29b7bebfd7963fa70d873a0e7 | Rust | Jasperav/cdrs | /src/load_balancing/round_robin.rs | UTF-8 | 1,751 | 3.296875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use std::cell::RefCell;
use super::LoadBalancingStrategy;
pub struct RoundRobin<N> {
cluster: Vec<N>,
prev_idx: RefCell<usize>,
}
impl<N> RoundRobin<N> {
pub fn new() -> Self {
RoundRobin {
prev_idx: RefCell::new(0),
cluster: vec![],
}
}
}
impl<N> From<Vec<N>>... | true |
e1f9a169684ddf4199c5b74831235f7f81427516 | Rust | bonega/chipsand | /src/serial.rs | UTF-8 | 1,861 | 3.0625 | 3 | [] | no_license | use crate::Interrupt;
pub struct SC {
sio_clk: bool,
sio_en: bool,
}
impl SC {
fn new() -> Self {
SC {
sio_clk: false,
sio_en: false,
}
}
pub fn read_word(&self) -> u8 {
((self.sio_en as u8) << 7) | 0b01111110 | self.sio_clk as u8
}
pub fn ... | true |
836ad654cc7cfe96f6847211469556984a5eb1a4 | Rust | dovahcrow/ml.rs | /src/pagerank/mod.rs | UTF-8 | 2,737 | 2.65625 | 3 | [] | no_license | //! Pagerank -- Pagerank Algorithm in Rust
#![stable]
#![deny(missing_doc)]
extern crate matrixrs;
extern crate libc;
use self::matrixrs::{Matrix,zeros,ToMatrix};
use self::libc::{c_ulong, c_double};
use std::mem::transmute;
use std::ptr;
#[cfg(not(test))]
#[no_mangle]
pub unsafe fn pagerank_c(
adjm: *const c_doubl... | true |
6de00db088fdb1187c43ba9a7faa34764cd013a2 | Rust | kmizu/rustlisp | /src/expr.rs | UTF-8 | 232 | 2.625 | 3 | [] | no_license | #![allow(dead_code)]
use std::marker::PhantomData;
pub struct Stuck;
pub struct Nothing;
pub trait Expr {
fn to_string() -> String;
}
impl Expr for Stuck {
fn to_string() -> String {
"stuck".to_string()
}
}
| true |
6494469643729a9fc428c8a05d58d0c9b7ce8ce2 | Rust | project-ela/siderow | /src/arch/x86/asm/item.rs | UTF-8 | 828 | 3.265625 | 3 | [
"MIT"
] | permissive | use super::Instruction;
#[derive(Debug)]
pub enum AssemblyItem {
Instruction(Instruction),
PseudoOp(PseudoOp),
Label(String),
}
#[derive(Debug)]
pub enum PseudoOp {
Data,
Global(String),
Text,
Zero(usize),
}
impl AssemblyItem {
pub fn stringify(&self) -> String {
use self::Ass... | true |
5abaefaedc793ce75563a7b1b71e0c9f94676a51 | Rust | RReverser/syn | /tests/test_meta.rs | UTF-8 | 1,082 | 2.515625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | extern crate syn;
mod features;
#[macro_use]
mod macros;
use syn::parse::Parse;
use syn::{Meta, MetaList, MetaNameValue, NestedMeta};
use std::fmt::Debug;
#[test]
fn test_parse_meta_item_word() {
let code = "hello";
snapshot!(code as Meta);
}
#[test]
fn test_parse_meta_name_value() {
test::<MetaNameVa... | true |
12b24ebfaddcdb29dd902e67d9170dbaa1fb8b22 | Rust | alex-dukhno/rust-tdd-katas | /old-katas-iteration-02/algebraic_expression_parser_kata/src/day_9.rs | UTF-8 | 4,239 | 3.90625 | 4 | [
"MIT"
] | permissive | use std::borrow::Cow;
use std::iter::Peekable;
use std::num::ParseFloatError;
use std::str::Chars;
#[derive(PartialEq, Debug)]
pub enum Ast {
Num(Result<f64, ParseFloatError>),
Operand(char, Box<Ast>, Box<Ast>)
}
pub struct Parser<'s> {
iter: Peekable<Chars<'s>>
}
impl <'s> Parser<'s> {
pub fn new(it... | true |
63b6327afd95d96af859f8749f8da6ce929f7763 | Rust | jfconde/rust-gb | /src/lib/ram.rs | UTF-8 | 251 | 2.859375 | 3 | [] | no_license | const RAM_SIZE: usize = 8192;
pub struct RAM {
data: [u8; RAM_SIZE]
}
impl RAM {
pub fn new () -> RAM {
debug!("Creating new RAM ({}KB)...", RAM_SIZE/1024);
RAM {
data: [0; RAM_SIZE]
}
}
} | true |
14cb92efd8fdadbdbfdcd4e57b56d32a384e5cd6 | Rust | nettok/euler-rust | /src/p001.rs | UTF-8 | 761 | 4.4375 | 4 | [
"Unlicense"
] | permissive | //! Multiples of 3 and 5
//! Problem 1
//!
//! If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9.
//! The sum of these multiples is 23.
//!
//! Find the sum of all the multiples of 3 or 5 below 1000.
pub fn imperative(below: usize) -> usize {
let mut sum = 0;
for x... | true |
42d5f34ff936f984f9b24b342e7466151216a168 | Rust | 9val/gdrive | /src/files/copy.rs | UTF-8 | 3,682 | 2.828125 | 3 | [
"MIT"
] | permissive | use crate::common::delegate::UploadDelegate;
use crate::common::delegate::UploadDelegateConfig;
use crate::common::drive_file;
use crate::common::hub_helper;
use crate::files;
use crate::files::info::DisplayConfig;
use crate::hub::Hub;
use std::error;
use std::fmt::Display;
use std::fmt::Formatter;
#[derive(Clone, Deb... | true |
c525de9d95146d0751effdda2e10a8f323f0a4b6 | Rust | cjstehno/rust-exercism | /bob/src/lib.rs | UTF-8 | 569 | 3.46875 | 3 | [] | no_license |
pub fn reply(input : &str) -> String {
return match input {
_ if is_nothing(input) => "Fine. Be that way!".to_string(),
_ if is_yelling(input) => "Whoa, chill out!".to_string(),
_ if is_question(input) => "Sure.".to_string(),
_ => "Whatever.".to_string()
... | true |
92fd5092177c993ae748ea239963efa6437afbe7 | Rust | RobJenks/advent-of-code | /2017/rust/day25/src/lib.rs | UTF-8 | 3,611 | 3.390625 | 3 | [] | no_license | pub fn run() {
println!("Part 1 result: {}", part1());
}
fn part1() -> usize {
let (mut tm, checksum) = parse_input(common::read_file("day25/input.txt"), 10_000);
tm.by_ref().take(checksum).last().unwrap();
tm.get_tape().iter().filter(|x| **x == 1).count()
}
#[derive(Debug)]
pub struct TuringMachine... | true |
cd985f62e68e0600b63273f47a3ebbf46ff6c572 | Rust | ducktail/aoj | /vol04/rust/q0417.rs | UTF-8 | 2,036 | 3.046875 | 3 | [] | no_license | use std::cmp::Ordering;
use std::collections::BinaryHeap;
use std::collections::VecDeque;
fn main(){
let nm: Vec<usize> = read_vec();
let n = nm[0];
let m = nm[1];
let mut vl: Vec<VecDeque<usize>> = vec![VecDeque::new();n];
let mut bh: BinaryHeap<Lane> = BinaryHeap::new();
for i in 0..n {
... | true |
70dacb80f16c5b467022999ec3edad41790c327e | Rust | panaman67/AdventOfCode2017 | /day9.rs | UTF-8 | 407 | 2.984375 | 3 | [] | no_license | use std::io::prelude::*;
use std::fs::File;
fn main()
{
let mut input_file = File::open("input_day9.txt").expect("cant find file");
let mut input = String::new();
input_file.read_to_string(&mut input).expect("Could not read into string");
//println!("{}", input);
//let mut test = input.replace("... | true |
a24368095fa9d9976823ba1058c18d7332bcbaed | Rust | matklad/fall | /fall/editor/src/actions.rs | UTF-8 | 3,539 | 2.796875 | 3 | [
"MIT"
] | permissive | use crate::EditorFileImpl;
use fall_tree::{File, TextUnit, TextEdit, Node, FileEdit, TextRange};
use fall_tree::search::{find_leaf_at_offset, Direction, LeafAtOffset, sibling};
use fall_tree::test_util;
pub fn default_context_actions(
file: &File,
range: TextRange,
actions: &mut Vec<&'static str>,
) {
... | true |
a856baec76568c857d6a5067d07d9cf7915bb477 | Rust | tinaun/aoc-2016 | /p6_signals/src/advent.rs | UTF-8 | 1,369 | 2.8125 | 3 | [] | no_license | /// advent of code
///
/// problem 6
///
/// decode repetition codes
pub static PROBLEM_NUMBER: &'static str = "6";
use std::collections::BTreeMap;
use std::sync::Arc;
use std::sync::mpsc;
use std::thread;
pub fn adv_main(input: Vec<String>) {
let length = input[0].len();
let mut output = vec!['\0'; l... | true |
c04206d81102ab8e9919ea5491246f053b855f0e | Rust | napi-rs/napi-rs | /examples/napi/src/enum.rs | UTF-8 | 617 | 2.953125 | 3 | [
"MIT"
] | permissive | use napi::bindgen_prelude::*;
/// default enum values are continuos i32s start from 0
#[napi]
pub enum Kind {
/// Barks
Dog,
/// Kills birds
Cat,
/// Tasty
Duck,
}
#[napi]
pub enum Empty {}
#[napi(string_enum)]
pub enum Status {
Pristine,
Loading,
Ready,
}
/// You could break the step and for an n... | true |
f1ca81b13eb27a97c954d8efc6f259e970e0f779 | Rust | HexColors60/r2vm | /lib/usernet/src/util.rs | UTF-8 | 2,287 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use parking_lot::Mutex;
use std::future::Future;
use std::pin::Pin;
use std::sync::Arc;
use std::task::{Context, Poll, Waker};
struct ReplaceableInner {
future: Option<Pin<Box<dyn Future<Output = ()> + Send>>>,
waker: Option<Waker>,
}
pub struct ReplaceableTask {
inner: Arc<Mutex<ReplaceableInner>>,
}
im... | true |
be88cd5f76a7e18f6100d7e56d591c1a8f44ef2e | Rust | JPMoresmau/ezregexp | /src/parser.rs | UTF-8 | 6,513 | 3.390625 | 3 | [
"MIT"
] | permissive | //! Parse a regular expression into a pattern
use crate::builder::Pattern;
use regex_syntax::ast::{
parse::Parser, Alternation, Assertion, AssertionKind, Ast, Class, ClassPerl, ClassPerlKind,
ClassUnicode, ClassUnicodeKind, Concat, Error, Group, GroupKind, Literal, Repetition, RepetitionKind,
RepetitionOp,... | true |
5b55c0a5620ca9578ffa781760fd07f9617795d7 | Rust | alakahakai/vector | /src/event/util/log/insert.rs | UTF-8 | 4,221 | 3.625 | 4 | [
"Apache-2.0"
] | permissive | use super::{PathComponent, PathIter, Value};
use std::{collections::BTreeMap, iter::Peekable};
/// Inserts field value using a path specified using `a.b[1].c` notation.
pub fn insert(fields: &mut BTreeMap<String, Value>, path: &str, value: Value) -> Option<Value> {
map_insert(fields, PathIter::new(path).peekable()... | true |
54464e7b506e6de4e851303434cecfc581f6beea | Rust | fuine/katome | /src/katome/prelude.rs | UTF-8 | 1,861 | 3.015625 | 3 | [
"Apache-2.0"
] | permissive | //! Basic type and const values declarations used throughout katome.
extern crate parking_lot;
use self::parking_lot::RwLock;
use compress::CHARS_PER_CARRIER;
/// Index type for both nodes and edges in the graph/gir.
pub type Idx = usize;
/// Type for representing weight of the `Edge`.
pub type EdgeWeight = u32;
/// ... | true |
cbb86233dce1919374fb3816fe22dc83b9b1e410 | Rust | matthew86707/Rust-GameDev-61b50f34dc21fde9c258a92e75bac6aa59bdb261 | /src/Camera.rs | UTF-8 | 2,786 | 2.5625 | 3 | [] | no_license | extern crate glium;
extern crate image;
extern crate nalgebra;
const NEAR_PLANE: f32 = 0.001;
const FAR_PLANE : f32 = 1000.0;
pub struct Camera{
pub rotation: nalgebra::Vector3<f32>,
pub position: nalgebra::Vector3<f32>
}
impl Camera{
pub fn new() -> Camera{
let mut translation: nalgebra::Vector3<f32> = nalge... | true |
ace0358cb65eb5e34d54bc6971668844b97d893c | Rust | sschalek/aoc_solutions | /rust/2015/p2015_8/src/main.rs | UTF-8 | 3,508 | 3.46875 | 3 | [
"MIT"
] | permissive | use std::io::BufRead;
fn input_lines() -> impl Iterator<Item=String> {
let input_file = std::fs::File::open("input.txt").expect("A file named \"input.txt\" with the problem data must be present in the current directory.");
// Create a line-based iterator for the file contents.
let reader = std::io::BufRea... | true |
47523920621a9f9035ab3fc049525adf377ad0af | Rust | AndrewGi/OpenMusicManager | /src/app/services/spotify/playlist.rs | UTF-8 | 3,600 | 2.5625 | 3 | [] | no_license | use crate::app::services::error::Error;
use crate::app::services::spotify::client::Client;
use crate::app::services::spotify::external_urls::ExternalURLs;
use crate::app::services::spotify::followers::Followers;
use crate::app::services::spotify::images::Image;
use crate::app::services::spotify::paging::PagingObject;
u... | true |
f07dd8b82d53c7531bee0bf375c3bc23a034baa7 | Rust | forensicmatt/RustyReg | /src/main.rs | UTF-8 | 5,297 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | #[macro_use] extern crate log;
extern crate serde_json;
extern crate env_logger;
extern crate jmespath;
extern crate clap;
extern crate rwinreg;
use rwinreg::hive;
use clap::{App, Arg, ArgMatches};
use jmespath::{Expression};
use std::fs;
fn process_directory(directory: &str, options: &ArgMatches) {
for dir_reader... | true |
d16a77ac8e0045e635d33225f5d63c67a60ecc9d | Rust | ADoublePlus/csvprs | /csvprs.rs | UTF-8 | 1,927 | 3.28125 | 3 | [] | no_license | use std::fs::File;
use std::io::Read;
#[allow(dead_code)]
pub struct CsvReader<'a>
{
file: &'a mut File,
data: Vec<Vec<String>>
}
impl<'a> CsvReader<'a>
{
#[allow(dead_code)]
pub fn from_file(file: &'a mut File) -> Self
{
CsvReader
{
file: file,
data: vec![... | true |
64ba0afe4cfbee5b65e480cb43f5f5630ccdcbcd | Rust | ootsby-forks/flocking_rust | /src/systems/draw_birds.rs | UTF-8 | 1,002 | 2.71875 | 3 | [] | no_license | use bbecs::world::World;
use ggez::{graphics, Context, GameResult};
use graphics::DrawParam;
use crate::component_names::ComponentNames;
use crate::resource_names::ResourceNames;
/// Query for the locations and then draw them out using GGEZ's draw method
pub fn draw_birds_system(
context: &mut Context,
world:... | true |
4cb0f2556fd09bc9405ad045c524da42d1333022 | Rust | FreddieRidell/hypertask | /rust/hypertask_engine/src/tag.rs | UTF-8 | 534 | 3.390625 | 3 | [] | no_license | use serde::{Deserialize, Serialize};
use std::fmt;
#[derive(Serialize, Deserialize, Debug)]
pub enum Sign {
Plus,
Minus,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct Tag {
pub sign: Sign,
pub name: String,
}
impl fmt::Display for Tag {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Re... | true |
91f77c9995a6d943fdd2bf03dffecf6d9e27862a | Rust | danalex97/dspa | /src/dto/person.rs | UTF-8 | 1,489 | 2.9375 | 3 | [] | no_license | extern crate chrono;
extern crate csv;
use crate::dto::common::Browser;
use crate::dto::common::Gender;
use crate::dto::common::Importable;
use chrono::{DateTime, FixedOffset, NaiveDate};
use csv::StringRecord;
use std::error::Error;
#[derive(Debug)]
pub struct Person {
pub id: u32,
pub first_name: String,
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.