1. String::from("This is a pen");
2. "This is a pen".to_string();
3. let s: String = "This is a pen".into(); // type annotations needed
4. "This is a pen".to_owned();
5. format!("This is a pen");
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"image/color" | |
"log" | |
"github.com/hajimehoshi/ebiten/v2" | |
"github.com/hajimehoshi/ebiten/v2/ebitenutil" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
format PE CONSOLE | |
entry start | |
include 'encoding\utf8.inc' | |
include 'win32w.inc' | |
section '.data' data readable writeable | |
name db '山田(yamada)', 0 | |
title TCHAR 'タイトル(title)', 0 | |
content TCHAR 'コンテンツ(content)', 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
const fmt = std.fmt; | |
const mem = std.mem; | |
const print = std.debug.print; | |
const assert = std.debug.assert; | |
const expect = std.testing.expect; | |
const Allocator = mem.Allocator; | |
// zig run singly_linked_list.zig | |
// zig test singly_linked_list.zig |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
cd "$(dirname "$0")" | |
exe_name=linked_list | |
# build -> debug mode (implicit) | |
# build debug -> debug mode | |
# build asan -> debug mode with asan | |
# build release -> release mode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <time.h> | |
#include "raylib.h" | |
#ifdef _DEBUG | |
#define WINDOW_TITLE "lifegame (debug)" | |
#else | |
#define WINDOW_TITLE "lifegame" | |
#endif |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10) | |
project(lifegame C) | |
set(CMAKE_C_STANDARD_REQUIRED True) | |
set(CMAKE_C_EXTENSIONS OFF) | |
file(GLOB SOURCES ${CMAKE_SOURCE_DIR}/src/*.c) | |
add_executable(${PROJECT_NAME} ${SOURCES}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.10) | |
# Debug build | |
# $ cmake -S . -B build/debug -GNinja -DCMAKE_BUILD_TYPE=Debug | |
# $ cmake --build build/debug -- basic_window && ./build/debug/basic_window.exe | |
# Release build | |
# $ cmake -S . -B build/release -GNinja -DCMAKE_BUILD_TYPE=Release | |
# $ cmake --build build/release -- basic_window && ./build/release/basic_window.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const std = @import("std"); | |
pub fn build(b: *std.Build) void { | |
const target = b.standardTargetOptions(.{}); | |
const optimize = b.standardOptimizeOption(.{}); | |
const lib_mod = b.createModule(.{ | |
.root_source_file = b.path("lib/mylib/mylib.zig"), | |
.target = target, | |
.optimize = optimize, |
NewerOlder