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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
c921bbdf0310878d49fcca99cc4b6256da5f30b9 | Rust | pac85/vulkano-events | /vulkano/src/image/view.rs | UTF-8 | 19,456 | 2.703125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference",
"Apache-2.0"
] | permissive | // Copyright (c) 2021 The vulkano developers
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or
// https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>,
// at your option. All files in the project carrying such
// notice may not be ... | true |
f053c845fa8897470e18002854f71d927a5573a3 | Rust | jleedev/rad | /src/main.rs | UTF-8 | 1,231 | 2.578125 | 3 | [] | no_license | #[macro_use] extern crate matches;
#[macro_use] extern crate nom;
extern crate rusqlite;
extern crate tempdir;
mod buffer;
mod command;
use std::io::{BufReader, BufRead, stdin};
use buffer::Buffer;
type Error = Box<std::error::Error>;
fn load_file(filename: &str) -> Result<Buffer, Error> {
let mut b = Buffer::... | true |
4e6070439a21af2da19c6efc3fdc81ad42213a71 | Rust | workanator/shapir | /src/error/mod.rs | UTF-8 | 4,494 | 3.296875 | 3 | [
"MIT"
] | permissive | //! Error type used in the library
mod service_error;
use std::{self, fmt};
use std::error::Error as StdError;
use serde_json::Value;
pub use std::io::Error as IoError;
pub use std::io::ErrorKind as IoErrorKind;
pub use hyper::error::Error as NetworkError;
pub use url::ParseError as UrlError;
pub use serde_json::e... | true |
f7304c20573d49f82d7409bf4545a8289a39463d | Rust | yeastplume/rust-sssmc39 | /src/shamir/sssmc39_scheme.rs | UTF-8 | 16,037 | 2.703125 | 3 | [
"LicenseRef-scancode-warranty-disclaimer",
"Apache-2.0"
] | permissive | // Copyright 2019 The Grin Developers
//
// 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 agree... | true |
747c3c7357fd687077bbc2549e2038bbe63fff40 | Rust | frankier/safe-transmute-rs | /src/lib.rs | UTF-8 | 11,250 | 3.328125 | 3 | [
"MIT"
] | permissive | //! This crate contains checked implementations of `transmute()`.
//!
//! The base functions in this crate are not inherently safe, but just guarded against common simple mistakes
//! (like trying to create an 8-byte type from 7 bytes).
//! These functions are exactly as safe as the data passed to them - creating a nul... | true |
9b3834705e345a88fefad915bf25ef9804dd5e3c | Rust | cedric-h/macroquad | /examples/life.rs | UTF-8 | 2,858 | 2.953125 | 3 | [] | no_license | use macroquad::{
clear_background, draw_texture, load_texture_from_image, next_frame, rand, screen_height,
screen_width, update_texture, Image, BLACK, WHITE,
};
#[macroquad::main("Life")]
async fn main() {
let w = screen_width() as usize;
let h = screen_height() as usize;
let mut buffer = vec![WHI... | true |
a71d88f37b3872c3c846267a8bc13f17a66c76b0 | Rust | BroderickCarlin/harma-rs | /notepad/src/mock_serial.rs | UTF-8 | 5,270 | 3.046875 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | //! Mock serial port for unit testing
use std::io::Write;
#[derive(Clone)]
pub struct MockSerial {
buffer: Vec<u8>,
}
impl std::default::Default for MockSerial {
fn default() -> Self {
MockSerial { buffer: vec![] }
}
}
impl std::io::Write for MockSerial {
fn write(&mut self, buf: &[u8]) -> st... | true |
10f080f81e45e276ed251a18096ad9736658b217 | Rust | n4oah-study/rust-startup | /basic03/collection/src/vector_basic.rs | UTF-8 | 1,854 | 4.21875 | 4 | [] | no_license | pub fn vector_basic_func() {
// push해주려면 mut을 써야 함
let mut vec1: Vec<i32> = Vec::new();
vec1.push(1);
vec1.push(2);
vec1.push(3);
vec1.push(4);
vec1.push(5);
println!("vec1: {:?}", vec1);
// 초기화 하면서 값을 넣을 수 있음
// immutable이기 때문에 새로운 값을 push할 수 는 없음
let vec2 = vec... | true |
ff89922e56c5b00a9ece4a35b078de32b3e6ce9e | Rust | eduardobraun/femapi | /src/schema.rs | UTF-8 | 7,145 | 2.625 | 3 | [
"MIT"
] | permissive | use super::db::models::{Member, NewMember, NewProject, Project, User};
use super::db::DbConn;
use super::db::Pool;
use super::diesel::prelude::*;
use super::filestore::{FileNode, FileStore};
use juniper::Context;
use uuid::Uuid;
pub struct Database {
pub current_user: Option<User>,
pub pool: Pool,
}
impl Cont... | true |
18aaccf7f0719bb42f2e0a403b05c68c003625f4 | Rust | ntdef/factotum | /src/factotum/fileparser/tests.rs | UTF-8 | 4,035 | 2.625 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-warranty-disclaimer"
] | permissive | /*
* Copyright (c) 2016 Snowplow Analytics Ltd. All rights reserved.
*
* This program is licensed to you under the Apache License Version 2.0, and
* you may not use this file except in compliance with the Apache License
* Version 2.0. You may obtain a copy of the Apache License Version 2.0 at
* http://www.apach... | true |
0da24ef747203a99a335442128b9ecfcc355768a | Rust | rust-windowing/winit | /src/platform_impl/web/web_sys/intersection_handle.rs | UTF-8 | 1,019 | 2.609375 | 3 | [
"Apache-2.0"
] | permissive | use js_sys::Array;
use wasm_bindgen::{prelude::Closure, JsCast};
use web_sys::{Element, IntersectionObserver, IntersectionObserverEntry};
pub(super) struct IntersectionObserverHandle {
observer: IntersectionObserver,
_closure: Closure<dyn FnMut(Array)>,
}
impl IntersectionObserverHandle {
pub fn new<F>(el... | true |
00b8926088f17118e802fecca7314dbcf9ea1143 | Rust | psinghal20/linkerd2-proxy | /linkerd/proxy/transport/src/tls/client.rs | UTF-8 | 3,851 | 2.515625 | 3 | [
"Apache-2.0"
] | permissive | use crate::io::BoxedIo;
use futures::{try_ready, Future, Poll};
use linkerd2_conditional::Conditional;
use linkerd2_identity as identity;
pub use rustls::ClientConfig as Config;
use std::io;
use std::sync::Arc;
use tokio::net::TcpStream;
use tracing::{debug, trace};
pub trait HasConfig {
fn tls_client_config(&self... | true |
03ec5665d43453ec193cb09fd2bf8dc8c209332d | Rust | dadu0699/Rust-Learning-Path | /Module 02/structs/src/main.rs | UTF-8 | 1,475 | 3.734375 | 4 | [] | no_license | // Classic struct with named fields
struct Student {
name: String,
level: u8,
remote: bool,
}
// Tuple struct with data types only
struct Grades(char, char, char, char, f32);
// Unit struct
struct Unit;
fn main() {
// Instantiate a classic struct, specify the fields in random order
let student_1 ... | true |
becedb8c6f283b5eab73f010108ab8dd72bdb734 | Rust | gnoliyil/fuchsia | /third_party/rust_crates/vendor/test-case-1.1.0/src/expected/mod.rs | UTF-8 | 4,053 | 2.609375 | 3 | [
"BSD-2-Clause",
"MIT"
] | permissive | pub mod expr_case;
pub mod ignore_case;
pub mod panic_case;
pub mod pattern_case;
#[cfg(any(feature = "hamcrest_assertions", test))]
pub mod hamcrest_case;
use crate::expected::expr_case::ExprCase;
use crate::expected::ignore_case::IgnoreCase;
use crate::expected::panic_case::PanicCase;
use crate::expected::pattern_c... | true |
94b94f810a240a1be37fddf8ec6ed7623feb9aa8 | Rust | TheDan64/advent_of_code | /src/day10.rs | UTF-8 | 2,092 | 2.96875 | 3 | [] | no_license | use std::{collections::HashSet, hash::Hash};
use aoc_runner_derive::aoc;
#[derive(Debug)]
enum Instruction {
Noop,
Addx(i32),
}
fn instructions(input: &str) -> impl Iterator<Item = Instruction> + '_ {
input.split('\n').map(|line| {
if line.starts_with("noop") {
Instruction::Noop
... | true |
71f84eeb4242b38dea527a48e11b3d80b0d2a144 | Rust | Sk3pz/erosion | /src/state.rs | UTF-8 | 5,549 | 2.65625 | 3 | [] | no_license | use winit::window::Window;
use winit::event::WindowEvent;
pub struct State {
surface: wgpu::Surface,
device: wgpu::Device,
queue: wgpu::Queue,
sc_desc: wgpu::SwapChainDescriptor,
swap_chain: wgpu::SwapChain,
pub(crate) size: winit::dpi::PhysicalSize<u32>,
}
impl State {
pub async fn new(wi... | true |
8ac59eaa4f07cf6b763718ab986e98183d026329 | Rust | kamalmarhubi/rust-bisect | /third_party/multirust-rs/rust-install/src/mock.rs | UTF-8 | 2,056 | 3.140625 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::fs::{self, OpenOptions, File};
use std::path::Path;
use std::io::Write;
// Mock of the on-disk structure of rust-installer installers
pub struct MockInstallerBuilder {
pub components: Vec<MockComponent>,
}
// A component name, the installation commands for installing files
// (either "file:" or "dir:") a... | true |
ed721d9a67558b80d999de491a4030c75b41ef94 | Rust | Ogek/aoc2020 | /src/day14.rs | UTF-8 | 3,847 | 3.375 | 3 | [] | no_license | use itertools::{EitherOrBoth::*, Itertools};
use serde_scan::scan;
use std::collections::HashMap;
#[derive(Debug)]
enum Instruction<'a> {
Mask(&'a str),
Malloc(usize, usize),
}
type BitMask = usize;
type Memory = HashMap<usize, usize>;
#[derive(Debug)]
struct DecoderChip<'a> {
and_mask: BitMask,
or_m... | true |
b0d4fc88f4ec7211f0061f0ab39de2e44117d351 | Rust | chryslovelace/advent-of-code-2020 | /src/bin/day15/main.rs | UTF-8 | 840 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
const STARTING_NUMBERS: &[usize] = &[0, 20, 7, 16, 1, 18, 15];
fn play_until(nth: usize) -> usize {
let mut spoken_numbers: HashMap<_, _> = STARTING_NUMBERS
.iter()
.copied()
.enumerate()
.map(|(a, b)| (b, a))
.collect();
let mut count = S... | true |
0ac9503b6e2dd6eafcee1c266b91df8ccdaf5ede | Rust | frainho/chip8 | /sdl2/src/rom_loader.rs | UTF-8 | 245 | 2.515625 | 3 | [] | no_license | use std::{error::Error, fs, path::PathBuf};
pub struct RomLoader;
impl RomLoader {
pub fn load_rom<P>(rom_path: P) -> Result<Vec<u8>, Box<dyn Error>>
where
P: Into<PathBuf>,
{
Ok(fs::read(rom_path.into())?)
}
}
| true |
f09397519149adf803f2a8615463142275b2e5d8 | Rust | pnkfelix/agents | /src/input.rs | UTF-8 | 4,151 | 3.015625 | 3 | [] | no_license | use glium::glutin;
use glium::glutin::VirtualKeyCode as VK;
use glium::glutin::Event;
use glium::glutin::KeyboardInput;
use std::collections::HashSet;
pub struct InputHandler {
keyset: HashSet<VK>,
mouseset: [bool; 2],
zoom: f32,
mouse_pos: (f64, f64),
mouse_pos_last_pressed: (f64, f64),
mo... | true |
ebc24d56b335e558d07d265a3c2d50020f040b22 | Rust | bgianfo/rust-run-down | /tests/unit-tests.rs | UTF-8 | 5,703 | 2.640625 | 3 | [
"MIT"
] | permissive | // Copyright 2019 Brian Gianforcaro
use pretty_assertions::assert_eq;
use run_down::{RundownError, RundownGuard, RundownRef};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::{sync::atomic::AtomicBool, sync::atomic::Ordering};
//-------------------------------------------------------------------... | true |
8940583ddb3eb814230b1e5b32c71106ccf6553e | Rust | frankegoesdown/LeetCode-in-Go | /Algorithms/0417.pacific-atlantic-water-flow/pacific-atlantic-water-flow.go | UTF-8 | 1,494 | 2.734375 | 3 | [
"MIT"
] | permissive | package problem0417
func pacificAtlantic(mat [][]int) [][]int {
res := [][]int{}
if len(mat) == 0 || len(mat[0]) == 0 {
return res
}
m, n := len(mat), len(mat[0])
// p[i][j] 表示,[i][j] 可以让水流到 Pacific 的点
// a[i][j] 表示,[i][j] 可以让水流到 Atlantic 的点
p, a := make([][]bool, m), make([][]bool, m)
for i := 0; i < m; i... | true |
e3672ca875482a6ee99f59066ad7df6e92b8569a | Rust | jramapuram/arrayfire-rust | /src/seq.rs | UTF-8 | 1,147 | 3.234375 | 3 | [] | no_license | extern crate libc;
use std::fmt;
use std::default::Default;
use self::libc::{c_double};
/// Sequences are used for indexing Arrays
#[derive(Copy, Clone)]
#[repr(C)]
pub struct Seq {
begin: c_double,
end: c_double,
step: c_double,
}
/// Default `Seq` spans all the elements along a dimension
impl Default f... | true |
153e91a8e218ce9761077d4ea30fdb1ff007dd9b | Rust | Dayscool/mini-dayscool | /back-end/ms_cursos/src/database/querys.rs | UTF-8 | 3,477 | 2.71875 | 3 | [] | no_license | pub mod curso {
use crate::schema::cursos;
use crate::schema::cursos::dsl::*;
use crate::models::curso;
use crate::CourseDB;
use diesel::*;
pub fn insert_curso(curs: curso::Insert::Curso, connection: CourseDB) -> QueryResult<usize> {
diesel::insert_into(cursos::table)
.values(c... | true |
518eb05cc76ae42c19bdc308eb423f9b90be163c | Rust | dawid2193487/tetrahedrane | /src/renderers/wireframe.rs | UTF-8 | 1,416 | 3.109375 | 3 | [
"MIT"
] | permissive | use orbclient;
use super::super::geometry;
/// Draw a triangle, from 9 floats representing vertice coordinates
#[allow(dead_code)]
pub fn triangle_p(x1: f32, y1: f32, z1: f32,
x2: f32, y2: f32, z2: f32,
x3: f32, y3: f32, z3: f32,
color: orbclient::Color, window: &... | true |
700b41a0d45bb8448add3d9c63842617cca34de0 | Rust | JosefBertolini/RustTicTacToe | /src/game_loop.rs | UTF-8 | 1,686 | 3.125 | 3 | [] | no_license | use crate::gameboard::{Gameboard};
use crate::space::Space;
use crate::input;
pub fn run() {
let mut game_board = Gameboard{board: Gameboard::new()};
let mut turn = true;
let mut counter = 0;
welcome_message();
loop {
println!("Current Board:");
game_board.print_board();
if ... | true |
ac10be237e102c90725d6858e6dd5bd27ed01f15 | Rust | utilForever/BOJ | /Rust/13159 - Array.rs | UTF-8 | 12,245 | 3.1875 | 3 | [
"MIT"
] | permissive | use io::Write;
use std::{
cmp::Ordering,
io::{self, BufWriter, StdoutLock},
str,
};
pub struct UnsafeScanner<R> {
reader: R,
buf_str: Vec<u8>,
buf_iter: str::SplitAsciiWhitespace<'static>,
}
impl<R: io::BufRead> UnsafeScanner<R> {
pub fn new(reader: R) -> Self {
Self {
... | true |
e9ff27d72db28e18518c891f66b57721748753b8 | Rust | barzamin/ppcheat | /src/main.rs | UTF-8 | 5,444 | 3.21875 | 3 | [] | no_license | use core::fmt;
mod parser;
use parser::parse_opcode;
#[derive(Debug, Copy, Clone, PartialEq)]
pub struct Register(pub u8);
impl fmt::Display for Register {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "r{}", self.0)
}
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum Opcode... | true |
6319d106b93eaeea717fd3ffc0647d2a57c5e29c | Rust | paulkirkwood/rs.parcoursdb | /tests/test_tour_of_italy.rs | UTF-8 | 176,341 | 2.828125 | 3 | [] | no_license | extern crate parcoursdb;
extern crate chrono;
#[cfg(test)]
mod test {
use parcoursdb::tour_of_italy::repository::*;
#[test]
fn test_tour_of_italy_1909() {
let route = [
"1,13 May,Milano to Bologna,397.0 km,Road stage",
"2,16 May,Bologna to Chieti,375.8 km,Road stage",
... | true |
e243fe3193e1dd61e72accdca556a1cc849182b2 | Rust | youngqqcn/RustNotes | /examples/add/mul-two/src/lib.rs | UTF-8 | 243 | 3.171875 | 3 | [] | no_license |
pub fn mul_two(x: i32) -> i32 {
x * 2
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
use super::*;
#[test]
fn test_mul_two() {
assert_eq!(4 , mul_two(2));
}
}
| true |
8ca883c9a503b86888de874d4e8354e085aacbc0 | Rust | ChristopherDRoberts/aoc2020 | /src/day11.rs | UTF-8 | 4,905 | 3.140625 | 3 | [] | no_license | use std::fs;
fn read_input(path: &str) -> Vec<Vec<char>> {
let mut grid = Vec::<Vec<char>>::new();
let input = fs::read_to_string(path).expect("Read Error");
for row in input.lines() {
let mut grid_row = Vec::new();
for col in row.chars() {
grid_row.push(col);
}
... | true |
de2a83b5ef40b9b26c718af5be2cc068191a4ad3 | Rust | alacritty/alacritty | /alacritty_terminal/src/config/scrolling.rs | UTF-8 | 1,438 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use serde::de::Error as SerdeError;
use serde::{Deserialize, Deserializer};
use alacritty_config_derive::{ConfigDeserialize, SerdeReplace};
/// Maximum scrollback amount configurable.
pub const MAX_SCROLLBACK_LINES: u32 = 100_000;
/// Struct for scrolling related settings.
#[derive(ConfigDeserialize, Copy, Clone, De... | true |
99296da3d02ae27debe0cd92ee423bbb7272f711 | Rust | sitegui/fast-quantiles | /src/algorithm/mod.rs | UTF-8 | 5,523 | 2.671875 | 3 | [
"MIT"
] | permissive | // mod incoming_merge_state;
// mod samples_compressor;
mod samples_tree;
// mod summary;
// pub use summary::Summary;
// #[cfg(test)]
// mod test {
// use super::*;
// use crate::quantile_generator::{QuantileGenerator, RandomGenerator};
// use crate::rank_to_quantile;
// use ordered_float::NotNan;
//... | true |
d8c39749a114f9ef0f4db45cf6861ff3e11716f3 | Rust | Rust-Linked-Data/qstore | /src/blank.rs | UTF-8 | 2,274 | 3.078125 | 3 | [
"MIT"
] | permissive |
use std::hash::{Hash, Hasher};
use uuid::Uuid;
use store::{StoreNode, StorageEngine};
use identifiers::InternalID;
use literal::Literal;
static BLANK_HASH_PREFIX: &'static str = "B:";
static BLANK_NODE_IDENTIFIER_TYPE: &'static str = "http://internal/blank";
#[derive(PartialEq, PartialOrd, Clone, Debug)]
pub struct... | true |
8851b03d388246f3779505c4469164af743c28be | Rust | ssoRL/bspts | /frontend/src/pages/signin.rs | UTF-8 | 3,988 | 2.859375 | 3 | [] | no_license | use yew::prelude::*;
use yew::services::fetch::{FetchTask};
use data::user::*;
use yew::format::{Json};
use crate::apis::{sign_in, FetchResponse};
use http::status::StatusCode;
use crate::data::*;
struct State {
user: NewUser,
saving: bool,
error_message: Option<String>,
}
#[derive(Properties, Clone)]
pub... | true |
27827241cfc0a3c6153c9f22d7ddb9c9446b6fe2 | Rust | ruhlio/rust-ipfs | /merkledag/src/node.rs | UTF-8 | 1,220 | 2.71875 | 3 | [
"MIT"
] | permissive | use protobuf::Message;
use multihash;
use error::Result;
use pb_merkledag::{PBNode, PBLink};
#[derive(Debug, Clone)]
pub struct Node {
pb_node: PBNode,
encoded: Vec<u8>,
hash: Vec<u8>,
}
impl Node {
pub fn new(data: Vec<u8>) -> Result<Node> {
let mut pb_node = PBNode::new();
pb_node.s... | true |
592bc0081cf78c564397b1478cf91c169e4c999c | Rust | davebryson/rapido | /modules/account/src/lib.rs | UTF-8 | 10,719 | 2.953125 | 3 | [
"Apache-2.0"
] | permissive | //!
//! Basic account support with an authenticator. Primarly used for development/testing.
//! Uses a 'Trust Anchor' approach to bootstrapping users: Genesis accounts can create other accounts.
//!
use anyhow::{bail, ensure};
use borsh::{BorshDeserialize, BorshSerialize};
use exonum_crypto::{hash, PublicKey, PUBLIC_KE... | true |
68c913d824648236c857cc1a74e104d8bd61a999 | Rust | reujab/enquote | /tests/lib.rs | UTF-8 | 2,397 | 3.21875 | 3 | [
"Unlicense"
] | permissive | extern crate enquote;
#[test]
fn enquote() {
assert_eq!(
enquote::enquote('"', r#""Fran & Freddie's Diner ☺\""#),
r#""\"Fran & Freddie's Diner ☺\\\"""#,
);
assert_eq!(enquote::enquote('"', ""), r#""""#);
assert_eq!(enquote::enquote('"', r#"""#), r#""\"""#);
assert_eq!(
enqu... | true |
9ac7ca9025cd8635c952594d05f49b1ce4553b35 | Rust | rust-lang/miri | /tests/pass/calls.rs | UTF-8 | 817 | 3.453125 | 3 | [
"MIT",
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | fn call() -> i32 {
fn increment(x: i32) -> i32 {
x + 1
}
increment(1)
}
fn factorial_recursive() -> i64 {
fn fact(n: i64) -> i64 {
if n == 0 { 1 } else { n * fact(n - 1) }
}
fact(10)
}
fn call_generic() -> (i16, bool) {
fn id<T>(t: T) -> T {
t
}
(id(42), id(... | true |
2bf472f6a7fa2413b905f4b6666aa97d4d07f51e | Rust | jeandudey/test | /src/main.rs | UTF-8 | 1,037 | 2.78125 | 3 | [] | no_license | use anyhow::Result;
/// Welcome to the test.
use std::{env, fs::File};
pub mod core;
#[tokio::main]
async fn main() -> Result<()> {
let task = core::Task::new();
// Get arguments, skip executable path.
let mut args = env::args_os();
args.next();
let transactions_filename = args
.next()
... | true |
e68df0942d3346e105b43b9de26ab754fb8c7cec | Rust | VWeidinger/rust-fosbos-sw | /aufgaben/3_haystack/l_haystack.rs | UTF-8 | 430 | 3.75 | 4 | [] | no_license | fn main() {
let haystack = "Es ist kurz vor 3 und ich will nach Hause!".to_string();
let needle = 's';
let count = count(&haystack, needle);
println!("Der Charakter '{}' ist {}. mal in dem Satz:'{}'", needle, count, haystack);
}
fn count(haystack: &String, needle: char) -> u64 {
let mut count = 0;... | true |
557acb5a10790998171ea7e3221c000f62b4db51 | Rust | Rufflewind/lebedev_laikov | /src/lib.rs | UTF-8 | 2,176 | 3.34375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | //! # [Lebedev–Laikov quadrature][wiki]
//! [wiki]: https://en.wikipedia.org/wiki/Lebedev_quadrature
//!
//! Approximates surface integrals over the sphere as:
//!
//! ```text
//! ∫ f(Ω) dΩ = ∫ f(θ, φ) sin(θ) dθ dφ ≈ 4 π ∑ₖ wₖ f(xₖ, yₖ, zₖ)
//! ```
//!
//! Note that the weights are normalized such that they sum to one.... | true |
f642627f3d569e4624cfcbd1d5d9c7306177ef9a | Rust | 2xsaiko/conlink | /src/client/str/mod.rs | UTF-8 | 4,559 | 2.59375 | 3 | [
"MIT"
] | permissive | use std::io::ErrorKind;
use std::sync::Arc;
use futures::task::Context;
use tokio::macros::support::{Pin, Poll};
use tokio::net::TcpStream;
use tokio::stream::{Stream, StreamExt};
use tokio::sync::{mpsc, Mutex};
use tokio_util::codec::LinesCodecError;
use async_trait::async_trait;
use net::NetClient;
use shared::Shar... | true |
bc40ebf80925eca334122272c13de1650a3c6ebb | Rust | SonicZentropy/tuix | /core/src/widgets/button.rs | UTF-8 | 5,272 | 3.1875 | 3 | [
"MIT"
] | permissive | #![allow(dead_code)]
use crate::entity::Entity;
use crate::mouse::*;
use crate::{BuildHandler, Event, EventHandler, Propagation, WindowEvent};
use crate::{Code, PropSet, State};
#[derive(Debug, Clone, PartialEq)]
pub enum ButtonEvent {
Pressed,
Released,
Press,
Release,
}
#[derive(Default, Debug)]
... | true |
7a3e17f4fdf0fe56848eecf1e5fc5cabc981d90b | Rust | chinakite/rust-algorithm | /src/sort/mergesort.rs | UTF-8 | 1,786 | 3.390625 | 3 | [
"MIT"
] | permissive | use std::cmp::Ordering;
pub fn mergesort<T>(arr: &mut [T]) where T: Ord + Copy {
if arr.len() <= 1 {
return
}
let len = arr.len();
let mut tmp_arr:Vec<T> = Vec::with_capacity(len);
unsafe {
tmp_arr.set_len(len);
}
sort_helper(arr, 0, (len-1), &mut tmp_arr, |a,b| a.cmp(b));... | true |
0b4e9d691825c291d768c62182261a3839123e24 | Rust | royvegard/aoc_2020 | /src/day13.rs | UTF-8 | 3,752 | 3.28125 | 3 | [
"MIT"
] | permissive | use std::collections::HashMap;
#[aoc_generator(day13)]
fn parse_input(input: &str) -> (usize, Vec<usize>) {
let mut a = input.lines();
let start_time = a.next().unwrap().parse::<usize>().unwrap();
let bus = a
.next()
.unwrap()
.split(',')
.map(|x| {
let n = x.par... | true |
69affe36c0140d4600eb1aba6ed3915ede15b5c8 | Rust | BeastNeedsMoreTorque/football-simulator | /src/core/src/club/player/happiness.rs | UTF-8 | 443 | 2.734375 | 3 | [
"Apache-2.0"
] | permissive | #[derive(Debug)]
pub struct PlayerHappiness {
positive: Vec<PositiveHappiness>,
negative: Vec<NegativeHappiness>
}
impl PlayerHappiness {
pub fn new() -> Self {
PlayerHappiness {
positive: Vec::new(),
negative: Vec::new()
}
}
}
#[derive(Debug)]
pub struct Posit... | true |
80e78f76ff5055c6c1d795f886b74a3df952b0a8 | Rust | wez/max32630 | /max32630_svd/src/aes/ctrl/mod.rs | UTF-8 | 18,499 | 2.78125 | 3 | [
"Apache-2.0",
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CTRL {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut ... | true |
881eb1303fbaa1d6410175a6e17217a4afde2817 | Rust | ManShanko/yarex | /crates/stingray/src/file/wwise_dep.rs | UTF-8 | 1,421 | 2.53125 | 3 | [
"MIT"
] | permissive | use std::convert::TryInto;
use std::io::Write;
// version? check
const VERSION: u32 = u32::from_be(0x05000000);
pub struct WwiseDep<'a> {
buffer: &'a [u8],
}
impl<'a> WwiseDep<'a> {
pub fn new(buffer: &'a [u8]) -> Self {
Self {
buffer,
}
}
}
impl<'a> super::FileReader<'a> for... | true |
3b1bf20bf883a08a57aec9323f40c15205ba4040 | Rust | raphlinus/synthesizer-io | /synthesizer-io-core/src/worker.rs | UTF-8 | 3,394 | 2.59375 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2017 The Synthesizer IO 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 ... | true |
a314ec3c1f72509e73693b2911ef3b1a5cd480ec | Rust | xmclark/manifest | /toml-schema-v1/src/opt_level.rs | UTF-8 | 1,583 | 3.109375 | 3 | [] | no_license | use serde::de;
use serde::ser;
use std::fmt;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct OptLevel(pub String);
impl<'de> de::Deserialize<'de> for OptLevel {
fn deserialize<D>(d: D) -> Result<OptLevel, D::Error>
where
D: de::Deserializer<'de>,
{
struct Visitor;
impl<'de> de::... | true |
b8a8c677c0fc07088aebfdca5ef05449c454d074 | Rust | 42triangles/rppal | /src/hal.rs | UTF-8 | 4,638 | 2.703125 | 3 | [
"MIT"
] | permissive | //! Miscellaneous `embedded-hal` trait implementations.
//!
//! The `hal` module consists of a collection of `embedded-hal` trait
//! implementations for traits that aren't tied to a specific peripheral.
//!
//! This module is only included when either the `hal` or `hal-unproven` feature
//! flag is enabled.
use core:... | true |
7251aa5e648778e798f9fca3d8b053c4be2e5868 | Rust | sackopotatoes/coin_tax | /src/lib.rs | UTF-8 | 1,784 | 2.8125 | 3 | [] | no_license | #![feature(test)]
#![feature(vecdeque_binary_search)]
// for benchmarking
// extern crate test;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, BufRead};
use std::path::Path;
use std::collections::{HashMap};
use thiserror::Error;
mod transaction;
mod portfolio;
#[derive(Error,... | true |
f5209d17eb0473b86f2324ca019ee8bb2376d451 | Rust | piscisaureus/runja | /src/main.rs | UTF-8 | 13,556 | 2.90625 | 3 | [] | no_license | #![type_length_limit = "1638329"]
use std::fmt;
use std::fmt::Write;
use std::fs;
use std::fs::File;
use std::io;
use std::ops::Deref;
use std::path::PathBuf;
use std::rc::Rc;
pub type Match = Result<Matcher, Matcher>;
pub type Capture = Result<(Matcher, Matcher), Matcher>;
#[derive(Clone)]
pub struct Matcher {
da... | true |
fc9e605111e6981f9e90d596ff390a336358cb14 | Rust | ChrisKeefe/685Rust | /ch4/slice/src/main.rs | UTF-8 | 1,456 | 4.0625 | 4 | [
"MIT"
] | permissive | fn main() {
// Take a string
let s_lit = "Hello world!";
let s = String:: from(s_lit);
// split and print
let hello_from_string = first_word(&s[..]);
println!("{}", hello_from_string);
let hello_from_slice_of_literal = first_word(&s_lit[..]);
println!("{}", hello_from_slice_of_literal);... | true |
f13be5504149674d72df8ea8601cfd0a1ae25955 | Rust | JM4ier/bitOS | /std/src/syscall.rs | UTF-8 | 1,238 | 2.515625 | 3 | [] | no_license | //! syscall module that allows for communication with the kernel
#![macro_use]
pub use dep::syscall::*;
// taken from https://github.com/kryo4096/RostOS/blob/master/rost_std/src/syscall.rs
global_asm! (
"
.global _syscall
_syscall:
int $0x80
ret
"
);
extern "C" {
pub fn _syscall(_rdi: u64, _rsi: u64, _... | true |
6dd094893c6886758577b3d81a3bf91a84f5b8c1 | Rust | arunma/datagen | /src/options.rs | UTF-8 | 1,535 | 2.8125 | 3 | [
"MIT"
] | permissive | use structopt::StructOpt;
use std::num::ParseIntError;
#[derive(Debug, StructOpt)]
#[structopt(
name = "docgen",
about = "An easy to use tool to generate fake data in bulk and export it as Avro, Parquet or directly into your database as tables"
)]
pub struct Args {
#[structopt(subcommand)]
pub command: Command... | true |
8e5b3dd0ea1db1941da043ff73e883698209118f | Rust | dgollub/dkg-webserver | /src/webserver/mod.rs | UTF-8 | 4,304 | 3 | 3 | [
"MIT"
] | permissive | use std::env;
use std::error::Error;
use std::fs;
use std::io::prelude::*;
use std::net::{Ipv4Addr, SocketAddrV4, TcpListener, TcpStream};
mod utils;
use utils::{
get_default_response_headers, get_response_headers_from_file, is_html_file,
parse_filename_from_request,
};
use super::threadpool::ThreadPool;
co... | true |
b84427515d6889c05154af717870333c3b038bfc | Rust | grzi/Voxpire-old-project | /src/engines/terrain/data_model.rs | UTF-8 | 2,016 | 3.15625 | 3 | [] | no_license | use rand::Rng;
use crate::utilities::geometry::coordinates::Coordinates;
use crate::engines::terrain::chunk::{Chunk, CHUNK_SIZE};
use crate::engines::terrain::square::Square;
use crate::engines::terrain::bloc::Bloc;
use crate::engines::blocs::bloc_type::BlocType;
#[derive(Debug)]
pub struct IslandTerrain {
seed: ... | true |
776c241e95871e85325ee6ac26eb4b1312061fa5 | Rust | twissel/backoff | /src/lib.rs | UTF-8 | 3,670 | 2.546875 | 3 | [] | no_license | #![feature(use_extern_macros)]
extern crate backoff_macro;
extern crate futures;
pub use backoff_macro::on_error;
pub use futures::{Async, Future};
use std::time::{Duration, Instant};
enum BackoffState<Fut>
where
Fut: Future,
{
Initial,
Processing(StateProcessing<Fut>),
Finished(Result<Fut::Item, Fut... | true |
d1c9b1f19697011fbf6696e46b56e621ad16e0ac | Rust | diamantisk/lunatic | /src/api/mailbox.rs | UTF-8 | 12,772 | 2.90625 | 3 | [
"MIT",
"Apache-2.0"
] | permissive | use std::future::Future;
use anyhow::Result;
use wasmtime::{Caller, FuncType, Linker, Trap, ValType};
use crate::{
api::{error::IntoTrap, get_memory},
message::Message,
state::ProcessState,
};
use super::{link_async2_if_match, link_if_match};
// Register the mailbox APIs to the linker
pub(crate) fn regi... | true |
c1db5fdb24183c68e9f764dbdeb9b75ef3a20947 | Rust | mystal/yharnam | /tests/test_plan/mod.rs | UTF-8 | 7,674 | 2.734375 | 3 | [
"MIT"
] | permissive | use std::fs;
use std::io;
use std::path::Path;
use prost::Message;
use yharnam::*;
#[derive(Debug, PartialEq, Eq)]
pub enum PlanStep {
Line(String),
Option(String),
Select(u32),
Command(String),
Stop,
}
impl PlanStep {
fn new(line: &str) -> Self {
let mut split_line = line.splitn(2, ... | true |
de3d2608b9685281f12563ff98d9a55aac0e9ff5 | Rust | chasahodge/rust_table_data | /src/datemod.rs | UTF-8 | 487 | 2.9375 | 3 | [] | no_license | extern crate chrono;
use chrono::prelude::*;
pub fn get_a_date(some_date: String) -> Date<Local> {
let sdate: Vec<&str> = some_date.split("/").collect();
let month: String = sdate[0].to_string();
let day: String = sdate[1].to_string();
let year: String = sdate[2].to_string();
let mm: u32 = month.p... | true |
f0aa60654a7aa1455bebe4cf006eace9ec628117 | Rust | soccer-fan/sailing_game | /src/view.rs | UTF-8 | 5,434 | 2.859375 | 3 | [] | no_license | use bevy::window::Windows;
use bevy::ecs::Res;
use bevy::prelude::*;
use crate::map::{TileType, GameMap};
use crate::player::{Player, TravelState};
use crate::config::GameConfig;
pub struct MainCamera;
pub struct UiCamera;
pub struct PlayerSprite;
pub fn setup_cameras(commands: &mut Commands,) {
commands // came... | true |
76c7adbc81e256ec78cb8fe7147d26c3568d49be | Rust | kristopherbullinger/rust-run-length-encode | /src/tests.rs | UTF-8 | 4,595 | 3.265625 | 3 | [] | no_license | #[cfg(test)]
#[derive(Debug)]
struct Item {
a: usize,
b: usize,
}
impl PartialEq for Item {
fn eq(&self, other: &Self) -> bool {
self.a.eq(&other.a)
}
}
impl Eq for Item {}
use super::*;
#[test]
fn returns_none_on_empty_source() {
let mut rle = "".chars().run_length_encode();
assert!(rl... | true |
195f72a6cb4995763616a459b53b996530480c2f | Rust | rohitjoshi/wirefilter | /engine/src/rhs_types/array.rs | UTF-8 | 1,228 | 2.84375 | 3 | [
"MIT"
] | permissive | use crate::{
lex::{Lex, LexResult},
strict_partial_ord::StrictPartialOrd,
types::{Array, GetType, Type},
};
use serde::Serialize;
use std::{borrow::Borrow, cmp::Ordering};
/// [Uninhabited / empty type](https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types)
/// for `array` with traits we need for... | true |
e85646f6308544b033c1c6edff8f8b25595921f4 | Rust | Luke-Callaghan23/fscript | /src/transpiler/implementations/fscript_if.rs | UTF-8 | 1,091 | 2.859375 | 3 | [] | no_license | use crate::{tokenizer::token_types::TokenOfInterest, types::types::CompilableSection};
use crate::tokenizer::types::{
TokenOrStream,
TokenStream
};
use crate::transpiler::types::{
CompilationInfo,
CompilationInstructions,
CompileType,
Info
};
pub fn implement_if () -> CompilationInstruction... | true |
76220e79bcfd363f8e069307b74cb3360de3a102 | Rust | reilleya/rustBoy | /src/core/mod.rs | UTF-8 | 30,667 | 2.875 | 3 | [] | no_license | mod registers;
mod memory;
mod rom;
mod interrupts;
mod display;
mod timer;
pub struct Core {
pub reg: registers::Registers,
pub mem: memory::Memory,
pub int: interrupts::Interrupts,
}
fn check_add_half_carry(a:u8, b:u8) -> bool {
let lower = a & 0xF;
let (_res, carry) = lower.overflowing_add(b & 0xF);
carry
}
... | true |
eed827ce796f20565b4a3caf115e50667d73c283 | Rust | samnolen/grin | /core/src/core/sumtree.rs | UTF-8 | 26,796 | 2.90625 | 3 | [
"Apache-2.0"
] | permissive | // Copyright 2016 The Grin Developers
// 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 t... | true |
a71dc45448c23f3e62929476045dff7f3f479256 | Rust | myrabetty/sudoku_solver_rust | /src/core/solver.rs | UTF-8 | 5,538 | 3.140625 | 3 | [] | no_license | use log::{debug, info, warn};
use ndarray::Array2;
use crate::core::model::{NonEmptyCell, EmptyCell, Guess, GridFunctions};
use crate::core::initialize_empty_cells::remove_placed_values;
use crate::core::solver_helper::{initialize_empty_values, find_new_guess};
use crate::core::utilities::get_quadrant;
use crate::core:... | true |
c30b48da61570a13a8755fb96b7492835e6ee85a | Rust | kicha0/delta-rs | /rust/src/delta_arrow.rs | UTF-8 | 12,985 | 2.671875 | 3 | [
"Apache-2.0"
] | permissive | //! Conversion between Delta Table schema and Arrow schema
use crate::schema;
use arrow::datatypes::{
DataType as ArrowDataType, Field as ArrowField, Schema as ArrowSchema, SchemaRef, TimeUnit,
};
use arrow::error::ArrowError;
use lazy_static::lazy_static;
use regex::Regex;
use std::convert::TryFrom;
impl TryFrom... | true |
2d8a3a0e2fc55d92d4f4f11581ba7862f4c464d3 | Rust | rlucas585/examtrainer | /src/exam/grades.rs | UTF-8 | 519 | 3.015625 | 3 | [] | no_license | use super::toml;
use super::ExamError;
#[derive(Debug)]
pub struct Grades {
pass: u32,
max: u32,
}
impl Grades {
pub fn new_from_toml(toml: toml::Grades) -> Result<Self, ExamError> {
if toml.pass > toml.max {
Err(ExamError::InvalidGrade)
} else {
Ok(Self {
... | true |
c343fe3937570da7c0ce2912599346869e0ecd9a | Rust | eturino/key-set.rs | /tests/contains_test.rs | UTF-8 | 480 | 2.9375 | 3 | [] | no_license | use key_set::KeySet;
#[test]
fn test_contains() {
let ks_none: KeySet<i32> = KeySet::None;
let ks_all: KeySet<i32> = KeySet::All;
let ks_some: KeySet<i32> = KeySet::Some(vec![1, 2, 3]);
let ks_aes: KeySet<i32> = KeySet::AllExceptSome(vec![1, 2, 3]);
assert!(ks_all.contains(&1));
assert!(!ks_no... | true |
cfbef035d5d57cc80408bd2246a4ad05bfe0c653 | Rust | xcaptain/rust-algorithms | /leetcode/src/p27.rs | UTF-8 | 2,039 | 3.578125 | 4 | [] | no_license | // https://leetcode-cn.com/problems/remove-element/
// remove_mut method is still in nightly till 2019-07-03
pub fn remove_element(nums: &mut Vec<i32>, val: i32) -> i32 {
while let Some(pos) = nums.iter().position(|x| *x == val) {
nums.remove(pos);
}
nums.len() as i32
}
pub fn remove_element_skip(... | true |
08d694d7d7d8264067fbbf51f99b98ccff58a8e7 | Rust | redzic/grass | /src/atrule/function.rs | UTF-8 | 558 | 2.625 | 3 | [
"MIT"
] | permissive | use codemap::Span;
use crate::{args::FuncArgs, scope::Scope, Token};
#[derive(Debug, Clone)]
pub(crate) struct Function {
pub scope: Scope,
pub args: FuncArgs,
pub body: Vec<Token>,
pos: Span,
}
impl PartialEq for Function {
fn eq(&self, other: &Self) -> bool {
self.pos == other.pos
}... | true |
534b0bac2fde8cb86b5bededdc073b7f473b773a | Rust | rudyryk/json-typedef-codegen | /crates/core/src/codegen/ast.rs | UTF-8 | 14,365 | 2.765625 | 3 | [
"MIT"
] | permissive | use crate::target::metadata::Metadata;
use crate::target::{NameableKind, OptionalPropertyHandlingStrategy, Target};
use jtd::form::TypeValue;
use jtd::{Form, Schema};
use std::collections::BTreeMap;
use teeter_inflector::string::singularize::to_singular;
#[derive(Debug)]
pub struct SchemaAst {
pub root: Ast,
p... | true |
a7d592f869960b7125f44599fe4529fa3a52db49 | Rust | doytsujin/googapis | /googapis/genproto/google.cloud.networkservices.v1beta1.rs | UTF-8 | 20,238 | 2.953125 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | /// Represents the metadata of the long-running operation.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct OperationMetadata {
/// Output only. The time the operation was created.
#[prost(message, optional, tag = "1")]
pub create_time: ::core::option::Option<::prost_types::Timestamp>,
/// Outpu... | true |
4f346570c1cabc202b5bcc8cc3dc40781a969257 | Rust | jbrandrick/anagram | /src/anagram2.rs | UTF-8 | 2,949 | 3.46875 | 3 | [] | no_license | use std::fs;
use md5;
struct Word {
string: String,
stripped: String
}
impl Word {
pub fn new(word_in: &str) -> Word {
Word {
string: word_in.to_string(),
stripped: strip_blanks(word_in)
}
}
fn contains(&self, string_in: &str) -> bool {
str... | true |
35c7522b52f9de14149709734677817ecaf498e7 | Rust | tesuji/rust_inline_bug | /src/y2020/day_05.rs | UTF-8 | 1,052 | 3.546875 | 4 | [] | no_license |
pub fn solve(){
const INPUT : &str = include_str!("../../inputs/2020/5");
let mut numbers = INPUT
.lines()
.map(bsp_to_number)
.collect::<Vec<u16>>();
println!("[PART 1] Max seat number {}", numbers.iter().max().unwrap());
numbers.sort();
let mut seat = numbers[0];
fo... | true |
3992cc322c9aaf997fe893f78547bdd447f3f1e1 | Rust | sshyran/imx8-rust | /imx8mm/src/lcdif/ctrl1_clr.rs | UTF-8 | 50,812 | 2.828125 | 3 | [] | no_license | #[doc = r" Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r" Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::CTRL1_CLR {
#[doc = r" Modifies the contents of the register"]
#[inline]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w... | true |
7e7ab731a74a5450338a9b92eb2238b6a480b7fe | Rust | tallen11/planet-forge | /src/renderer/ray.rs | UTF-8 | 623 | 3.390625 | 3 | [] | no_license | use renderer::primitive::point::Point;
use renderer::primitive::vec3::Vec3;
#[derive(Copy, Clone, Debug)]
pub struct Ray {
origin: Point,
direction: Vec3,
}
impl Ray {
pub fn new(origin: Point, direction: Vec3) -> Ray {
Ray {
origin: origin,
direction: direction.normalized(... | true |
ee8bcecebd40e1b7849f121ca82a90a8388c71ac | Rust | nisarhassan12/materialize | /src/repr/src/timestamp.rs | UTF-8 | 8,868 | 2.875 | 3 | [
"Apache-2.0",
"BSD-2-Clause",
"CC0-1.0",
"BSD-3-Clause",
"MPL-2.0",
"0BSD",
"PostgreSQL",
"GPL-1.0-or-later",
"GPL-2.0-only",
"MIT",
"BUSL-1.1"
] | permissive | // Copyright Materialize, Inc. and contributors. All rights reserved.
//
// Use of this software is governed by the Business Source License
// included in the LICENSE file.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by ... | true |
17fe4b3c0716bc5cb8be085291f18b0713afd56b | Rust | mozilla/gecko-dev | /third_party/rust/libudev/src/context.rs | UTF-8 | 1,096 | 2.78125 | 3 | [
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | use std::path::Path;
use ::device::{Device};
use ::handle::{Handle};
/// A libudev context.
pub struct Context {
udev: *mut ::ffi::udev
}
impl Drop for Context {
fn drop(&mut self) {
unsafe {
::ffi::udev_unref(self.udev);
}
}
}
#[doc(hidden)]
impl Handle<::ffi::udev> for Cont... | true |
b513674d79cbbf6da485cac679a1381efaa6f37c | Rust | km19809/Pusher | /src/lib.rs | UTF-8 | 5,643 | 3.171875 | 3 | [
"LicenseRef-scancode-unknown-license-reference",
"MIT"
] | permissive | //! Simple CLI clone of sokoban
#[cfg(feature = "tui")]
use crossterm::{
cursor::MoveTo,
event::{read, Event, KeyCode},
execute,
style::Print,
terminal::{
disable_raw_mode, enable_raw_mode, Clear, ClearType, EnterAlternateScreen,
LeaveAlternateScreen, SetTitle,
},
};
use std::er... | true |
275970f4e5f06a52628c6c23deb7aacdf49e2e35 | Rust | CoffeeAndCode/mdquote | /tests/cli.rs | UTF-8 | 1,631 | 2.6875 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | mod support;
use std::str;
use support::{binary, binary_with_input};
#[test]
fn single_line_of_text() {
let process = binary_with_input(b"hello world")
.wait_with_output()
.expect("failed to read from stdout");
assert!(process.status.success());
assert_eq!("> hello world\n", str::from_utf... | true |
40d30e03ddac61180609a97bff4d673ca0976542 | Rust | vincentserpoul/funicular | /src/commands/config.rs | UTF-8 | 3,864 | 2.859375 | 3 | [
"Apache-2.0",
"MIT"
] | permissive | use crate::config::apk_overlay::APKOverlay;
use color_eyre::eyre::Result;
use gumdrop::Options;
use std::fs::File;
use std::io::prelude::*;
use std::path::{Path, PathBuf};
use thiserror::Error;
#[derive(Debug, Options)]
pub struct ConfigOpts {
#[options(help = "config file related command, gen, list")]
pub hel... | true |
c0581b9d75c94977e0240fb79f3d7c017fabb035 | Rust | alexcrichton/ars | /src/main.rs | UTF-8 | 7,343 | 2.625 | 3 | [] | no_license | // MSVC .lib specs:
// http://kishorekumar.net/pecoff_v8.1.htm
use std::collections::HashMap;
use std::env;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::{self, SeekFrom};
use std::mem;
use std::slice;
use std::str;
const MAG: [u8; 8] = *b"!<arch>\n";
const FMAG: [u8; 2] = *b"`\n";
... | true |
c4adec0b43f7fd11e3c7bdf154aeebdb2228306f | Rust | arusahni/git-req | /src/remotes/github.rs | UTF-8 | 4,282 | 2.953125 | 3 | [
"MIT"
] | permissive | use crate::remotes::{MergeRequest, Remote};
use anyhow::{anyhow, Result};
use log::{debug, trace};
use regex::Regex;
use serde_derive::{Deserialize, Serialize};
#[derive(Debug)]
pub struct GitHub {
pub id: String,
pub domain: String,
pub name: String,
pub origin: String,
pub api_root: String,
p... | true |
2cad516a4fc3a626b4669793143f73482ec90fc3 | Rust | jedhsu/geometry | /1-euclidean/base/atom/point.rs | UTF-8 | 811 | 3.171875 | 3 | [] | no_license | //! A point in Euclidean space.
use geometry::hilbert;
pub trait X<N, D>: hilbert::X
where
N: Dimension,
D: Datatype,
{
fn new(coordinates: Coordinates) {}
}
/// A point in a one-dimensional Euclidean space.
pub mod x1 {
pub struct X1<Axel, Size> {
a: Axel<Size>,
}
impl X1<Axel, Size... | true |
09874f321fa805c8d7f0eb8409daa34bb694c922 | Rust | gitter-badger/Kiln | /kiln_lib/src/lib.rs | UTF-8 | 59,151 | 2.6875 | 3 | [
"MIT"
] | permissive | pub mod avro_schema {
pub const TOOL_REPORT_SCHEMA: &str = r#"
{
"type": "record",
"name": "ToolReport",
"fields": [
{"name": "application_name", "type": "string"},
{"name": "git_branch", "type": ["null", "string"]},
{"name"... | true |
d8ff38f7f09946a109b9163023fb681725b60a40 | Rust | JohnTitor/garando | /garando_pos/src/hygiene.rs | UTF-8 | 7,434 | 2.78125 | 3 | [
"Apache-2.0",
"MIT",
"LicenseRef-scancode-unknown-license-reference"
] | permissive | //! Machinery for hygienic macros, inspired by the MTWT[1] paper.
//!
//! [1] Matthew Flatt, Ryan Culpepper, David Darais, and Robert Bruce Findler.
//! 2012. *Macros that work together: Compile-time bindings, partial expansion,
//! and definition contexts*. J. Funct. Program. 22, 2 (March 2012), 181-216.
//! DOI=10.10... | true |
aa9261ef8de948dd9a1087caccc7ebd33a74ab41 | Rust | nomalab/rust-color | /src/color.rs | UTF-8 | 993 | 3 | 3 | [
"MIT"
] | permissive | use num;
pub trait Color: Clone + PartialEq {
type Tag;
type ChannelsTuple;
fn num_channels() -> u32;
fn to_tuple(self) -> Self::ChannelsTuple;
}
pub trait FromTuple: Color {
fn from_tuple(values: Self::ChannelsTuple) -> Self;
}
pub trait PolarColor: Color {
type Angular;
type Cartesian;... | true |
423fd5662604e362b036091584459837fd86a957 | Rust | SCOTT-HAMILTON/programming-languages-little-benchmark | /bench_rust/src/main.rs | UTF-8 | 1,228 | 3.0625 | 3 | [
"MIT"
] | permissive | use std::time::Instant;
type ULL = u64;
const MAX1: ULL = 950;
const MAX_LOOP: ULL = 1000;
const MAX2: ULL = 38;
fn f(it_cur: &mut ULL, it_total: &mut ULL, result: &mut f64) -> ULL {
if *it_cur as ULL == MAX1 {
return *it_cur;
}
*it_cur += 1;
*it_total += 1;
*result += ((3123456.... | true |
c0b78d508ee66702ea4a54006dc32e08f14f706d | Rust | lynch829/telium | /src/numeric/function.rs | UTF-8 | 263 | 3.171875 | 3 | [] | no_license |
/// Trait returning a value from a function
pub trait Eval {
fn value(&self, x: f32) -> f32;
}
/// Trait to determine domain of a function
pub trait Domain {
/// returns true if x in the domain of the funtions
fn in_domain(&self, x: f32) -> bool;
}
| true |
adbd05ffff2ee12e820d6ea24be94e833243c209 | Rust | relistan/cryptorust | /crypto.rs | UTF-8 | 5,337 | 2.953125 | 3 | [
"BSD-2-Clause"
] | permissive | extern mod std;
use std::{io, vec, ptr, os};
use std::libc::{c_uint};
mod crypto {
use std::libc::{c_uint};
#[link_args = "-lcrypto"]
extern {
fn SHA1(src: *u8, sz: c_uint, out: *u8) -> *u8;
fn MD5(src: *u8, sz: c_uint, out: *u8) -> *u8;
fn SHA224(src: *u8, sz: c_uint, out: *u8) -> *u8;
fn SHA256... | true |
c573201dec88b3b033b8fedddb1a87466903116c | Rust | winding-lines/weaver | /weaver/src/local_store/epics.rs | UTF-8 | 628 | 2.671875 | 3 | [] | no_license | //! Manages the epic information. Since this is a short lived client and the json_store is simple
//! we initiate the store on demand.
use super::json_store;
use lib_error::*;
/// Save this epic name in the local storage,
/// does not change the current store.
pub fn save_epic(name: String) -> Result<()> {
let mut... | true |
f6261a3284cb09cc781495a1519a5da9a5aef97f | Rust | finegeometer/graham_mod_n | /src/main.rs | UTF-8 | 4,514 | 3.71875 | 4 | [] | no_license | /// Calculate `(base ^ exponent) % modulus`.
/// Uses the method of repeated squaring.
/// `O(log n)` time.
fn modexp(base: u32, mut exponent: u32, modulus: u32) -> u32 {
let mut base = base as u64;
let modulus = modulus as u64;
let mut out = 1;
while exponent > 0 {
if exponent & 1 > 0 {
... | true |
745600bf98b0d7389af58006fe3c60af847325f3 | Rust | jfroche/advent2019 | /src/bin/day10.rs | UTF-8 | 6,981 | 3.203125 | 3 | [] | no_license | use log::*;
use rust_decimal::prelude::*;
use std::collections::HashMap;
use std::fs;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt)]
#[structopt(name = "day10", about = "Advent of Code - Day 10")]
struct Opt {
/// Activate debug mode
// short and long flags (-d, --debug) will be ... | true |
2d54375d48052e377b27f6913bdf21208519a18f | Rust | kiwiyou/muroba | /src/util.rs | UTF-8 | 1,235 | 2.765625 | 3 | [
"Apache-2.0"
] | permissive | use std::io::Write;
use crossterm::{cursor, queue, style::Print, terminal};
use unicode_width::UnicodeWidthStr;
use crate::{item::Overflow, style::Styler, Result};
pub fn trim_print<S>(style: &S, f: &mut impl Write, content: &str) -> Result<()>
where
S: Styler<Overflow>,
{
let mut str = trim_overflow(content... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.